I want to search document in elastic search which has either tag a or b or c with the following query. But it always return the document which has only c and ignore a or b. Any one can help it out?
"filtered": {
"filter": {
"term": {
"tags": ['a','b','c']
}
},
"query": {
match: {
rawText: 'filter'
}
}
}
In Elasticsearch, there is a difference between the term and the terms filter.
Term Filter:
{
"constant_score" : {
"filter" : {
"term" : { "user" : "kimchy"}
}
}
}
Terms Filter:
{
"constant_score" : {
"filter" : {
"terms" : {
"user" : ["kimchy", "elasticsearch"],
"execution" : "bool",
"_cache": true
}
}
}
}
Try using the terms filter.
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