0
votes

I'm trying to create a query with elasticsearch to filter the records of the same city and price.

But the city filter is not working.

POST diadeturista/services/_search
{
   "query":{
      "bool":{
         "must":[

         ],
         "filter":{
            "bool":{
               "must":{
                  "terms":{
                     "city":[
                        "Contagem"
                     ]
                  },
                  "range":{
                     "price_adult":{
                        "lte":"300",
                        "gte":"150"
                     }
                  }
               }
            }
         }
      }
   }
}

SHow me this error:

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

1

1 Answers

0
votes

I think what you want todo is

{
    "query":{
        "bool":{
            "must": [
                {
                    "terms":{
                        "city":[
                            "Contagem"
                        ]
                    }
                },
                {
                    "range":{
                        "price_adult":{
                            "lte":"300",
                            "gte":"150"
                        }
                    }
                }
            ]
        }
    }
}