I want to get all documents that match the words: Apples, Oranges, and Pineapples in the field Fruit. So basically I want something like this:
{
"query":{
"bool":{
"must": [
{
"match": {
"fruits": ["Apples","Oranges","Pineapples"]
}
}
]
}
}
}
How do I accomplish this with a simple trick like that?
You can use "terms" in place of "match" to get the documents
{
"query": {
"terms": {
"fruits": [
"apples",
"oranges",
"pineapples"
]
}
}
}
Note: You should lowercase the values because "terms" query find exact matching and if no analyser is used default analyser (Standard Analyzer) is used by elasticsearch while indexing text values which lowercased the values before indexing it
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With