我有一个像这样的文档,其中interactInfo是嵌套的Document。我需要单独找到标题(细分)的汇总,而不是标题(订单)的汇总
{
"interactionId": "a26617a0-0530-4b41-9db6-4ca53e83e63e",
"interactionInfo": [
{
"title": "segments",
"value": "1"
},
{
"title": "Order",
"value": "2"
}
]
},
{
"interactionId": "a26617a0-0530-4b41-9db6-4ca53e83e63e",
"interactionInfo": [
{
"title": "segments",
"value": "4"
},
{
"title": "Order",
"value": "3"
}
]
}
]
这是我所做的汇总
"aggs": {
"InteractionInfo": {
"nested": {
"path": "interactionInfo"
},
"aggs": {
"interactionInfoFilter": {
"filter": {
"term": {
"interactionInfo.title.keyword": "segments"
}
},
"aggs": {
"SUM": {
"sum": {
"script": "Integer.parseInt(doc['interactionInfo.value.keyword'].value)"
}
}
}
}
}
}
}
我对以上汇总的响应是
"aggregations": {
"InteractionInfo": {
"doc_count": 6,
"interactionInfoFilter": {
"doc_count": 0,
"SUM": {
"value": 0
}
}
}
}
我期望的是仅返回标题的总计(细分),即值必须为5,但返回0 还有其他方法可以找到仅针对标题(细分)的集合