我修改了一个查询,在聚合后不得不应用过滤器,但是现在我在结果集中看到了不同的项目。现在几乎完全忽略了带有[“filters”] [“bool”] [“should”]的项目。
这可以正常工作:
"query": {
"bool": {
"must": {
...
},
"filter": {
"bool": {
"should": [{
"term": {
"any_pickup_options": true
}
}, {
"term": {
"local_delivery": true
}
}],
"must": [{
"term": {
"active": true
}
}]
}
}
}
}
这是失败的原因:
"query": {
"bool": {
"must": {
...
}
}
},
"post_filter": {
"bool": {
"should": [{
"term": {
"any_pickup_options": true
}
}, {
"term": {
"local_delivery": true
}
}],
"must": [{
"term": {
"active": true
}
}]
}
}
考虑了[“post_filters”] [“bool”] [“must”]约束。但是结果集不包含将
any_pickup_options
或local_delivery
设置为true的任何项目。
最佳答案
得到它了。您必须在过滤器上下文中指定minimum_should_match。
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html
关于elasticsearch - post_filter产生的结果与普通过滤器不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48509883/