Zabs
Zabs

Reputation: 14142

malformed query, expected END_OBJECT but found FIELD_NAME error in Kibana (Elastic Search)

I am running the following GET query within my Kibana Console and for some reason I am getting a error in the response window as follows :

// error

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

Can anyone suggest why I am not able to use multiple match blocks within the 'should' section?

// response - if i take out one of the match blocks it works??

{
  "error": {
   "root_cause": [
     {
       "type": "parsing_exception",
       "reason": "[match] malformed query, expected [END_OBJECT] but found [FIELD_NAME]",
        "line": 9,
        "col": 13
     }
   ],
    "type": "parsing_exception",
    "reason": "[match] malformed query, expected [END_OBJECT] but found [FIELD_NAME]",
    "line": 9,
    "col": 13
   },
   "status": 400
}

// my query

GET _search
  {
    "query": {
      "bool": {
        "should": [
        {
           "match": {
           "text": "facebook advice"
        },
           "match": {
           "profile": "facebook advice"
        }
      }
    ],
    "minimum_number_should_match": 1,
    "filter": {
      "term": {
        "accountid": "22"
      }
    }
  }
}

Upvotes: 27

Views: 71545

Answers (2)

muks
muks

Reputation: 17

Give the below query a try.. It works for me.

-------- working console query -------------

POST /usage-metering-stats/_search?size=10
{
  "query": {
    "bool": {
      "must": [{
                    "term": {
                        "tenantId": "2222"
                    }
                },
                {
                    "term": {
                        "instanceId": "1212"
                    }
                },
                {
                    "term": {
                        "cspId": "25680"
                    }
                },
                {
                    "term": {
                        "api": "2"
                    }
                }
            ]
      }
  },
  "aggs": {
    "totalCount": { "sum": { "field": "count" } }
  }
}

Upvotes: 0

Val
Val

Reputation: 217304

Your query is malformed. Write it like this instead:

GET _search
{
  "query": {
    "bool": {
      "should": [
        {
          "match": {
            "text": "facebook advice"
          }
        },
        {
          "match": {
            "profile": "facebook advice"
          }
        }
      ],
      "minimum_number_should_match": 1,
      "filter": {
        "term": {
          "accountid": "22"
        }
      }
    }
  }
}

Upvotes: 33

Related Questions