SELECT * FROM Customers WHERE City IN ('Paris','London')
How to convert above query in elasticsearch..
SELECT * FROM Customers WHERE City IN ('Paris','London')
How to convert above query in elasticsearch..
You may use terms query
GET _search
{
"query" : {
"terms" : {
"city" : ["Paris", "London"]
}
}
}
However, please make sure that your mapping has city marked as not_analyzed
In order to make your searches case insensitive, there are two ways I can think of :
match query instead of terms query. Terms query doesn't work on analyzed fields.A sample lowercase analyzer would look like this :
"analyzer": {
"lowercase_analyzer": {
"type": "custom",
"tokenizer": "keyword",
"filter": [
"lowercase",
"asciifolding"
]
}
}
Your query should look like:
The POST request:
http://localhost:9200/Customers/_search? <--assuming customers as your index
and the request BODY:
"query":{
"query_string":{
"query":"City:(Paris London)"
}
}
IN acts like : in ES. Hope this helps!