How can I write multiple search with grater that less than query?

How can I use grater than and less than with should match query in elasticsearch ?

    
{
    "query": {
        "range" : {
            "rate" : {
                "gte" : 0.6,
                "lte" : 1,
                "boost" : 2.0
            }
        },
            "bool": {
      "should": [
        { "match": { "target": "kairaba blue dreams resort spa" }},
        { "match": { "why": "A’la Carte Restoran,Kum Plaj,Çakıl Plaj" }}
        
      ]
    }
    }
}

Error:

{

  "error": {

    "root_cause": [

      {

        "type": "parsing_exception",

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

        "line": 11,

        "col": 13

      }

    ],

    "type": "parsing_exception",

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

    "line": 11,

    "col": 13

  },

  "status": 400

}

I believe you need to write something like:

{
   "query":{
      "bool":{
         "must":[
            {
               "range":{
                  "rate":{
                     "gte":0.6,
                     "lte":1,
                     "boost":2.0
                  }
               }
            }
         ],
         "should":[
            {
               "match":{
                  "target":"kairaba blue dreams resort spa"
               }
            },
            {
               "match":{
                  "why":"A’la Carte Restoran,Kum Plaj,Çakıl Plaj"
               }
            }
         ]
      }
   }
}
1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.