【发布时间】:2016-07-07 15:49:41
【问题描述】:
我正在运行一个带有聚合的弹性搜索查询,我打算将其限制为 100 条记录。问题是即使我应用了“大小”过滤器,对聚合也没有影响。
GET /index_name/index_type/_search
{
"size":0,
"query":{
"match_all": {}
},
"aggregations":{
"courier_code" : {
"terms" : {
"field" : "city"
}
}
}}
结果集是
{
"took": 7,
"timed_out": false,
"_shards": {
"total": 10,
"successful": 10,
"failed": 0
},
"hits": {
"total": 10867,
"max_score": 0,
"hits": []
},
"aggregations": {
"city": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "Mumbai",
"doc_count": 2706
},
{
"key": "London",
"doc_count": 2700
},
{
"key": "Patna",
"doc_count": 1800
},
{
"key": "New York",
"doc_count": 1800
},
{
"key": "Melbourne",
"doc_count": 900
}
]
}
}
}
如您所见,对限制要执行聚合的记录没有影响。是否有过滤器,例如 Elastic Search 中的前 100 条记录。
【问题讨论】:
标签: elasticsearch