如何在弹性搜索中删除重复的搜索结果? [英] How to remove duplicate search result in elasticsearch?
本文介绍了如何在弹性搜索中删除重复的搜索结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
首先创建一些示例数据(e1,e2,e3是类型,测试是索引名称):
First Create some example data (e1,e2,e3 are types and test is the index name):
PUT test/e1/1
{
"id":1
"subject": "subject 1"
}
PUT test/e2/1
{
"id":1
"subject": "subject 2"
}
PUT test/e3/2
{
"id":2
"subject": "subject 3"
}
现在我的问题是:如何获取这两个数据?删除卷曲-XGET _search
结果中相同ID的重复数据。
Now my question is: how can I get just these two data? remove duplicate data with the same id in the curl -XGET _search
result.
test/e1/1
{
"id":1
"subject": "subject 1"
}
test/e3/2
{
"id":2
"subject": "subject 3"
}
推荐答案
首先,您需要搜索多个索引。
然后,结果删除重复的ID。
First you will need to search across multiple index.
Then, on the result remove the duplicate ID.
POST http://myElastic.com/test/e1,e2,e3/_search
{
"aggs":{
"dedup" : {
"terms":{
"field": "id"
},
"aggs":{
"dedup_docs":{
"top_hits":{
"size":1
}
}
}
}
}
}
这可能有助于您:
- 搜索多索引类型
- / filter-elasticsearch-results-to-contain-only-unique-documents-based-on-one-field>过滤器弹性搜索结果仅包含基于一个字段值的唯一文档
- search multi-index type
- Remove duplicate documents from a search in Elasticsearch
- Filter elasticsearch results to contain only unique documents based on one field value
这篇关于如何在弹性搜索中删除重复的搜索结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文