NoviceCoder
NoviceCoder

Reputation: 519

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

My DSL query is shown below. For some reason when I run it in Kibana CLI, it tells me:

enter image description here

GET elastic-search-app-log*/_search
{
  "size": 42,
  "query": {
    "range": {
      "dateRanges": {
        "gte": "2021-05-20T10:15:00",
        "lte": "2021-05-18T14:58:00"
      }
    },
    "match": {
      "level": "Error"
    }
  }
}

I checked to see if maybe its the alignment of the braces but they look fine. Is there something causing this message?

Upvotes: 0

Views: 1320

Answers (1)

Bhavya
Bhavya

Reputation: 16192

You need to combine all the queries using bool/must clause

{
  "size": 42,
  "query": {
    "bool": {
      "must": [
        {
          "range": {
            "dateRanges": {
              "gte": "2021-05-20T10:15:00",
              "lte": "2021-05-18T14:58:00"
            }
          }
        },
        {
          "match": {
            "level": "Error"
          }
        }
      ]
    }
  }
}

Upvotes: 2

Related Questions