我的所有文档都有一个uid带有ID 的字段,用于将文档链接到用户.有多个文件相同uid.
我想对所有文档执行搜索,只返回每个唯一的最高得分文档uid.
选择相关文档的multi_match查询是简单查询.
我目前遇到的一个问题是,当我开始时似乎并不难为我解决,但我现在卡住了几个小时,所以我们走了:
给定这个对象数组:
groups = [
{
name: 'Custard apple',
slug: 'custard-apple',
children: [
{
name: 'Vanilla',
slug: 'vanilla',
children: [
{
name: 'Strawberry',
slug: 'strawberry',
children: []
}, {
name: 'Pineapple',
slug: 'pineapple',
children: []
}
]
}, {
name: 'Chocolate',
slug: 'chocolate',
children: []
}
]
}, {
name: 'Raspberry',
slug: 'raspberry',
children: []
}, {
name: 'Lemon',
slug: 'lemon',
children: [
{
name: 'Orange',
slug: 'orange',
children: [
{
name: 'Coconut',
slug: 'coconut',
children: []
}
]
}, …Run Code Online (Sandbox Code Playgroud)