我正在寻找类似未解决的question
的方法也许这是不可能做到的,唯一的解决方案是以编程方式做到这一点。我查看了管道聚合,但要么无法做到这一点,要么不了解如何使用特定的管道。
这是示例输出(当然,使用错误数据进行了简化)
"aggregations": {
"potatoeEvents": {
"doc_count": 21,
"potatoes": {
"doc_count": 21,
"nature": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "Yellow",
"doc_count": 6,
"bag": {
"doc_count": 0,
"size": {
"value": 0
}
}
},
{
"key": "Red",
"doc_count": 6,
"bag": {
"doc_count": 0,
"size": {
"value": 0
}
}
}
]
}
}
},
"bananaEvents": {
"doc_count": 18,
"bananas": {
"doc_count": 18,
"nature": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "Yellow",
"doc_count": 3,
"tree": {
"doc_count": 3
}
}
}
}
}
}
这是我想要的输出:
"aggregations": {
"potatoeEvents_bananasEvents": {
"doc_count": 21,
"potatoes_bananas": {
"doc_count": 21,
"nature": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "Yellow",
"doc_count": 6,
"bag": {
"doc_count": 0,
"size": {
"value": 0
}
},
"tree": {
"doc_count": 3
}
},
{
"key": "Red",
"doc_count": 6,
"bag": {
"doc_count": 0,
"size": {
"value": 0
}
}
}
]
}
}
}
}
如您所见,我正在同一查询中聚合两种类型的文档(这很好)。桶ID也相同。可以对这些聚合进行后处理以获得我想要的东西吗?