【发布时间】:2021-09-28 11:21:53
【问题描述】:
我有一个弹性搜索索引
喜欢
{
"title": "A",
"comments": [
{
"id": "1"
},
{
"id": "2"
}
]
},
{
"title": "B",
"comments": [
{
"id": "1"
},
{
"id": "3"
}
]
},
{
"title": "C",
"comments": [
{
"id": "7"
},
{
"id": "3"
}
]
}
我要折叠的是由嵌套对象组成的组。在上面的 JSON 中,我想按 Id 分组。 所以输出会是这样的
hits:[{
"title": "A",
"comments": [
{
"id": "1"
},
{
"id": "2"
}
]
},
inner_hits {[
{
"title": "A",
"comments": [
{
"id": "1"
},
{
"id": "2"
}
]
},
{
"title": "B",
"comments": [
{
"id": "1"
},
{
"id": "3"
}
]
}
]}
}]
基本上我需要基于嵌套对象属性的折叠基础。
试过了
/_search?track_total_hits=true
{
"collapse": {
"field": "comments.id",
"inner_hits": {
"name": "id",
"size": 10
},
"max_concurrent_group_searches": 3
}
}
但它总是只在内部点击中返回第一个对象
【问题讨论】:
标签: json elasticsearch search elasticsearch-5