georgetovrea
georgetovrea

Reputation: 577

How to perform a Elastsearch multi_match AND a BOOL together?

i have try to use the query as below ,

 {
   "query":{
      "bool":{
         "must":[
            {
               "range":{
                  "@timestamp":{
                     "from":"2018-09-01T08:35:11.000Z",
                     "to":"2018-10-01T08:35:11.000Z"
                  }
               }
            },
            "multi_match":{
               "query":"世界の人々の祝祭、第23回冬季",
               "fields":"message"
            }
         ]
      }
   },
   "from":0,
   "size":10000
}

but get the error message :

{
  "error" : {
    "root_cause" : [
  {
        "type" : "json_parse_exception",
        "reason" : "Unexpected character (':' (code 58)): was expecting comma to separate Array entries\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@4eacc26c; line: 21, column: 27]"
      }
  },
  "status" : 500
}

but if without timestamp range ,it's works

"query": {
    "multi_match": {
      "query": "世界の人々の祝祭、第23回冬季",
      "fields": [
        "message"
      ]
     }
 }

What is wrong in the request ? How to perform a multi_match AND a BOOL together ?

Upvotes: 0

Views: 36

Answers (1)

Val
Val

Reputation: 217304

You need to wrap the multi_match query inside curly braces as well

 {
   "query":{
      "bool":{
         "must":[
            {
               "range":{
                  "@timestamp":{
                     "from":"2018-09-01T08:35:11.000Z",
                     "to":"2018-10-01T08:35:11.000Z"
                  }
               }
            },
            {
              "multi_match":{
                 "query":"世界の人々の祝祭、第23回冬季",
                 "fields":"message"
              }
            }
         ]
      }
   },
   "from":0,
   "size":10000
}

Upvotes: 1

Related Questions