1

ElasticSearch returns me "query_parsing_exception","reason":"[bool] query does not support " error when trying to look up entries using the following query.i think the problem is about "query_string"

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
                               }
                       }
               },
          "query_string" : {
          "default_field" : "_all",
          "query" : "word1 OR word1",

          } ]
       }
   }
 }'

Why does this error appear?

Thanks


anyhelp will be appreciated ! thanks!

matt.crawfoord
  • 87
  • 1
  • 3
  • 13

1 Answers1

4

It usually helps to properly format your queries. In your case, you're missing a curly brace before query_string and you have one too many comma after your query_string query.

Reformating like this will work:

curl -XGET '<myurl>:<myport>/index/_search?pretty' -d '
{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "ip": "1.2.3.4"
          }
        },
        {
          "range": {
            "localtime": {
              "from": "2016-06-15T06:00:04.923Z",
              "to": "2016-06-17T17:43:04.923Z",
              "include_lower": true,
              "include_upper": true
            }
          }
        },
        {
          "query_string": {
            "default_field": "_all",
            "query": "word1 OR word1"
          }
        }
      ]
    }
  }
}'
Val
  • 207,596
  • 13
  • 358
  • 360