我有一个具有以下值的索引,我需要对答案数组的每个索引执行聚合。以下是我的 ES 索引中存在的数据
[
{
"answers": [
{
"value": "statement1"
},
{
"value": "statement2"
},
{
"value": "statement3"
}
]
},
{
"answers": [
{
"value": "statement2"
},
{
"value": "statement1"
},
{
"value": "statement3"
}
]
}
]
我需要知道特定索引处不同值的计数, 这意味着我需要有关数组每个位置的响应计数的信息因此我需要聚合 aa 如下
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 9,
"relation": "eq"
},
"max_score": null,
"hits": []
},
"aggregations": {
"Nest": {
"doc_count": 2,
"answers": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "index0",
"doc_count": 4,
"statement1": 1,
"statement2": 1,
"statement3": 0
},
{
"key": "index1",
"doc_count": 4,
"statement1": 1,
"statement2": 1,
"statement3": 0
},
{
"key": "index2",
"doc_count": 2,
"statement1": 0,
"statement2": 0,
"statement3": 1
}
]
}
}
}
}