Convert mysql to elasticsearch

I try to convert a sql search query to elasticsearch query from elasticsearch documantation, but samething are worng anyone can help me?

I have a document with same fields like age and city. i need search a people with 40 years old and don't live in the city Umapine.

My mysql code is samething like this:

SELECT *
FROM bank
WHERE age = 40 and city != Umapine

and in elasticsearch code i try to do samething like this:

{
   "query" : {
       "constant_score" : { 
         "filter" : {
            "bool" : {
            	"should" : { "term" : {"age" : 40} },
                "must_not" : { "term" : {"city" : "Umapine"} }
           }
         }
      }
   }
}

But samething are worng, anyone know what is worng?

Could you provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

Also you did not share what result you get. Neither the elasticsearch version.

Anyway, try with umapine instead of Umapine.

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