繁体   English   中英

Elasticsearch忽略聚合中的过滤器

[英]Elasticsearch Ignoring Filter in Aggregations

该请求看起来像:

{
    "aggs": {
        "contentType": {
            "terms": {
                "field": "contentType",
                "size": 0
            }
        }
    },
    "query": {...},
    "filter": {...}
}

响应类似于:

{
    "took": 300,
    "timed_out": false,
    "_shards": {
        "total": 1,
        "successful": 1,
        "failed": 0
    },
    "hits": {
        "total": 68,
        "max_score": 0,
        "hits": []
    },
    "aggregations": {
        "contentType": {
            "doct_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": [
                {
                    "key": 9
                    "doc_count": 7054
                },
                {
                    "key": 9
                    "doc_count": 7054
                },
                {
                    "key": 5
                    "doc_count": 6236
                },
                {
                    "key": 4
                    "doc_count": 1124
                }
            ]
        }
    }
}

聚合中的“ doc_count”就是没有“过滤器”而只有“查询”的结果。 “过滤器”似乎被忽略了。

在某些时候这是可行的,但是突然之间似乎并没有奏效。 有人有任何线索吗?

Elasticsearch 1.5.2,NEST 1.4.3。

谢谢。

DSL查询顶层使用的filter已重命名为post_filter (请参阅https://github.com/elastic/elasticsearch/issues/4119 )。 post_filter文档在这里: https : post_filter

我不确定它是否适用于您的特定查询,但是您可能想使用filtered查询类型: https : //www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-过滤,query.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM