Well,不要刷屏了

ES 如何针对数组类型字段结果进行分页

Elasticsearch | 作者 chanzz | 发布于2022年10月18日 | 阅读数:1277

我有一组查询结果,如下代码片段: 
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 5,
"relation": "eq"
},
"max_score": "1.0",
"hits": [
{
"_index": "search_test",
"_type": "_doc",
"_id": "1",
"_score": "1.0",
"_source": {
"linkId": [
"111",
"222"
]
}
},
{
"_index": "search_test",
"_type": "_doc",
"_id": "2",
"_score": "1.0",
"_source": {
"linkId": [
"222",
"333"
]
}
},
{
"_index": "search_test",
"_type": "_doc",
"_id": "3",
"_score": "1.0",
"_source": {
"linkId": [
"222",
"333"
]
}
},
{
"_index": "search_test",
"_type": "_doc",
"_id": "4",
"_score": "1.0",
"_source": {
"linkId": [
"333",
"444"
]
}
},
{
"_index": "search_test",
"_type": "_doc",
"_id": "5",
"_score": "1.0",
"_source": {
"linkId": [
"555",
"666"
]
}
}
]
}
}
现在我想拿出 linkId 中的数据,并对其进行去重再分页,有办法能做到吗
已邀请:

Charele - Cisco4321

赞同来自:

没明白你要哪一种
1 如果你是要在DSL里面直接处理,加个pipeline聚合
 
2 如果你是对结果进行处理,可能更简单,
前提是用Java操作。
High level 客户端的结果是可以取到你要的结果的

要回复问题请先登录注册