1

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.

0

1 Answer 1

1

[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"
          }
        }
      ]
    }
  }
}
Sign up to request clarification or add additional context in comments.

1 Comment

Hey Bhavya, Thanks for the quick response. Yes it is correct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.