我正在尝试在Elastic Search中将一些分组的数据分组到超集存储桶中,但找不到。
我的查询如下:
GET /items/_search
{
"query" : {
"match_all": {}
},
"size": 0,
"aggs": {
"group_by_item" : {
"terms": {
"field": "category"
}
}
}
}
这将产生以下内容:
{
...
"aggregations": {
"group_by_category": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 1278,
"buckets": [
{
"key": "Plane",
"doc_count": 15482
},
{
"key": "Bike",
"doc_count": 10740
},
{
"key": "Car",
"doc_count": 9566
}
]
}
}
}
我想归为新类别,可以是“飞什么”和“什么驱动”:
{
...
"aggregations": {
"group_by_category": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 1278,
"buckets": [
{
"key": "Flies",
"doc_count": 15482
},
{
"key": "Drives",
"doc_count": 20306
}
]
}
}
}