dimanche 24 juillet 2016

Nested query in elasticsearch error

ElasticSearch returns me "[_na] query malformed, no field after start_object" error when trying to look up entries using the following query. The field localtime is a new field of documents and exist in every document.

curl -XGET '<myurl>:<myport>/index/_search?pretty' -d '
{
  "query": {
  "bool": {
  "must":[ {
  "term" : {
    "query" : "1.2.3.4",
    "fields" : [ "ip" ]
  }
}, {
  "range" : {
    "localtime" : {
      "from" : "2016-06-15T06:00:04.923Z",
      "to" : "2016-06-17T17:43:04.923Z",
      "include_lower" : true,
      "include_upper" : true
    }
  }
} ]
 }
}
}'

my php,

 $qryurl = '<myurl>:<myport>/index/_search?pretty';
                $data = array(
                    "query" => array (
                    "bool" => array (
                        "must" => array (
                                   "range" => array ( 
                                   "localtime"  => array( 
                                        "from" =>"2016-06-15T17:43:04.923Z",
                                        "to" => "2016-06-17T17:43:04.923Z",
                                        "include_lower" => "true",                     
                                        "include_upper" => "true"
                                              )
                                                ),
                                "term" => array ( 
                                   "ip" => "1.2.3.4" 
                                        )

                                       )
                )


            )
        );

Why does this error appear?

Thanks


anyhelp will be appreciated ! thanks!

Aucun commentaire:

Enregistrer un commentaire