我想使用以下查询在 Elasticsearch 中搜索具有标签 a 或 b 或 c 的文档。但它总是返回只有 c 而忽略 a 或 b 的文档。任何人都可以帮助它吗?
"filtered": {
"filter": {
"term": {
"tags": ['a','b','c']
}
},
"query": {
match: {
rawText: 'filter'
}
}
}
最佳答案
在 Elasticsearch 中,术语和术语过滤器之间存在差异。
术语过滤器:
{
"constant_score" : {
"filter" : {
"term" : { "user" : "kimchy"}
}
}
}
术语过滤器:
{
"constant_score" : {
"filter" : {
"terms" : {
"user" : ["kimchy", "elasticsearch"],
"execution" : "bool",
"_cache": true
}
}
}
}
尝试使用术语过滤器。
关于elasticsearch - 数组中的术语过滤器只考虑最后一项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31770247/