I have the following SQL query:
SELECT * FROM
table WHERE
area IN ('UK', 'US', 'France')
AND rating IN ('GOOD', 'BAD','AVG')
AND active = 'YES'
I want to convert it to an elastic query.
Please see my attempt at 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 this doesnt help me with the score because of all these matches being inside filter. Is there a way to move all these "must" matches to a "query" so that I can get scored results?
I am specifically looking a way to convert the SQL query I have above to elastic search query with all conditions inside a "query" instead of "filter"
Thanks very much.