【发布时间】:2019-12-17 02:20:36
【问题描述】:
很抱歉,如果已经有人问过这个问题,但一直潜伏在 SO 周围,找不到任何适合我需要的东西。
基本上,我在使用 ES 的第一次快速尝试中想要实现的是在术语聚合中添加更多计数器。
快速尝试一下,我正在向 ES 发送以下请求。
POST http://localhost:9200/people/_search
{
"size": 0,
"aggs": {
"agg_by_name": {
"terms": { "field": "name"}
}
}
}
而我现在得到的正是文档中示例显示的内容。
{
"took": 89,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 10000,
"relation": "gte"
},
"max_score": null,
"hits": []
},
"aggregations": {
"agg_by_name": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 9837,
"buckets": [
{
"key": "James",
"doc_count": 437
},
{
"key": "Eduard",
"doc_count": 367
},
{
"key": "Leonardo",
"doc_count": 235
},
{
"key": "George",
"doc_count": 209
},
{
"key": "Harrison",
"doc_count": 180
}, ...
但是,我真的不知道如何在存储桶中包含更多内部聚合。会导致这样的文档。
{
"key": "Harrison",
"doc_count": 180,
"lives_in_NY": 40,
"lives_in_CA": 140,
"distinct_surnames": [ ... ]
}
我应该如何构建我的聚合,以便按桶包含这些聚合?
【问题讨论】:
标签: elasticsearch elasticsearch-aggregation