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

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -