sql - Elasticsearch query (not filter) with multiple fields and conditions -


i have following sql query:

select *  table  area in  ('uk', 'us', 'france')   , rating in ('good', 'bad','avg')   , active = 'yes'  

i want convert elastic query.

please see attempt @ using "filter" below:

{   "query" : {     "filtered" : {       "query" : {         "match_all" : {}       },       "filter" : {         "bool" : {           "must" : [{               "terms" : {                 "area" : [                   "uk",                   "us",                   "france"                 ]               }             },              {               "terms" : {                 "rating" : [                   "good",                   "bad",                   "avg"                 ]               }             },              {               "term" : {                 "active" : "yes"               }             }           ]         }       }     }   } } 

however doesnt me score because of these matches being inside filter. there way move these "must" matches "query" can scored results?

i looking way convert sql query have above elastic search query conditions inside "query" instead of "filter"

thanks much.

you can use bool query instead of bool filter. query converted to:

{  "query": {   "bool": {      "must" : [{           "terms" : {             "area" : [               "uk",               "us",               "france"             ]           }         },          {           "terms" : {             "rating" : [               "good",               "bad",               "avg"             ]           }         },          {           "term" : {             "active" : "yes"           }         }       ]     }    }   } 

now conditions in query not in filter.hope helps.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -