Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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"
      }
    }
  }
}
like image 963
Zabs Avatar asked Jun 01 '17 11:06

Zabs


1 Answers

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"
        }
      }
    }
  }
}
like image 51
Val Avatar answered Sep 27 '22 11:09

Val