【发布时间】:2017-03-07 21:42:30
【问题描述】:
我正在尝试使用基数聚合来计算不同值。
这是我的查询
{
"size": 100,
"_source":["awardeeName"],
"query": {
"match_phrase":{"awardeeName" :"The President and Fellows of Harvard College" }
},
"aggs":{
"awardeeName": {
"filter" : { "query": { "match_phrase":{"awardeeName" :"The President and Fellows of Harvard College" }}},
"aggs": {
"distinct":{"cardinality":{ "field": "awardeeName"}}
}
}
}
}
使用 match_phrase 查询某些文本,使用相同的匹配短语进行聚合,然后调用基数, 结果,命中数和聚合过滤器匹配,但基数显示的数字比过滤器和总命中数惊人地大,这是结果
{
"took": 37,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 3,
"max_score": 13.516766,
"hits": [
{
"_index": "development",
"_type": "document",
"_id": "140a3f5b-e876-4542-b16d-56c3c5ae0e58",
"_score": 13.516766,
"_source": {
"awardeeName": "The President and Fellows of Harvard College"
}
},
{
"_index": "development",
"_type": "document",
"_id": "5c668b06-c612-4349-8735-2a79ee2bb55e",
"_score": 12.913888,
"_source": {
"awardeeName": "The President and Fellows of Harvard College"
}
},
{
"_index": "development",
"_type": "document",
"_id": "a9560519-1b2a-4e64-b85f-4645a41d5810",
"_score": 12.913888,
"_source": {
"awardeeName": "The President and Fellows of Harvard College"
}
}
]
},
"aggregations": {
"awardeeName": {
"doc_count": 3,
"distinct": {
"value": 7
}
}
}
}
我希望基数适用于过滤器的结果,但在这种情况下基数显示 7 ,为什么显示 7 ?不同值的计数如何超过总点击数?
【问题讨论】:
标签: elasticsearch