elasticsearch - post_filter产生的结果与普通过滤器不同

标签 elasticsearch

我修改了一个查询,在聚合后不得不应用过滤器,但是现在我在结果集中看到了不同的项目。现在几乎完全忽略了带有[“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_optionslocal_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/

相关文章:

python - 任何人都可以使用 python 给出 Elasticsearch 的快照示例吗?

elasticsearch - 用于 Golang 的 Olivere 包中的 BulkIndexer 用于替换 Elastigo

elasticsearch - java.io.IOException:启动k8s elasticsearch集群pod时无法在/usr/share/elasticsearch/data/nodes/0上获得锁

Elasticsearch 过滤查询与过滤器

python-2.7 - python中的ElasticSearch AND查询

elasticsearch - 如何在Elasticsearch中对多值字段进行桶聚合

elasticsearch - 指定多个字段时,elasticsearch simple_query_string查询是否使用dis_max或bool组合查询?

node.js - 没有消息的putMapping invalid_argument_exception

Elasticsearch 错误 "bootstrap checks failed"(绑定(bind)非环回地址)

elasticsearch - Curator_cli V5.8禁用日志记录?