简体   繁体   中英

Problem with Elasticsearch query - [range] malformed query, expected [END_OBJECT] but found [FIELD_NAME]

I am unable to figure out what is wrong with below query.

GET website/_search
{
  "query": {
    "bool": { 
      "filter": [
        {
          "range": {
            "@timestamp": {
            "gte": "now-1d/d",
            "lt": "now/d"
            }
          },
          "match": {
            "aspnet-request-url.keyword": "abc.com/Default.aspx"
          }
        }
      ] 
    }
  }
}

Both range and match are working fine independently.

As per documentation, it says when merging more than one query we should use either must , filter , must-not under bool query.

Still it is giving [range] malformed query, expected [END_OBJECT] but found [FIELD_NAME] .

Any help is appreciated.

[range] malformed query, expected [END_OBJECT] but found [FIELD_NAME]

It is clear from the above error, that the query is not properly formed. Please refer to this to know more about the structure of the query and filter context .

You are missing some brackets, try out the below search query

{
  "query": {
    "bool": {
      "filter": [
        {
          "range": {
            "@timestamp": {
              "gte": "now-1d/d",
              "lt": "now/d"
            }
          }
        },
        {                          <-- note this
          "match": {
            "aspnet-request-url.keyword": "abc.com/Default.aspx"
          }
        }
      ]
    }
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM