Can anyone tell me how do I write the below Mysql query in elastisearch
Select * from `table` WHERE `Name`='A' OR `Name`='B' order by `rank` DESC
I have tried multiple solutions the internet like
{
"sort":{"rank":{"order":"desc"}},
"query": {
"query_string" : {
"fields" : ["Name"],
"query" : "A OR B"
}
}
and also tried the below code
{
"sort":{"rank":{"order":"desc"}},
"query" : {
"bool": {
"should": [
{
"match_phrase" : {
"Name" : "A"
}
},
{
"match_phrase": {
"Name": "B"
}
}
]
}
}
}
You could do it with Bool-Filter and Order on all Documents:
Or have a subset with Range Query:
This is my current mappings are
Try Terms filter. Below is equivalent of SQL query you wrote.