请求类似于:
{
"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。
感谢。
答案 0 :(得分:4)
filter
已重命名为post_filter
(请参阅https://github.com/elastic/elasticsearch/issues/4119)。 post_filter
的文档位于:https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-post-filter.html
我不确定它是否适用于您的特定查询,但您可能希望使用filtered
查询类型:https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-filtered-query.html