gpt4 book ai didi

elasticsearch - 如何在elasticsearch中删除以前索引的文档?

转载 作者:行者123 更新时间:2023-12-03 00:17:41 24 4
gpt4 key购买 nike

我有两个文件的索引如下
文件1

{
"_index": "custom-design",
"_type": "cars",
"_id": "porche129",
"_score": 1.2413527,
"_source": {
"clientID": "ps1233443",
"customisation": "yes",
"userType": "heavy",
"totalBilling": 3000
}
}

}

文件2
{
"_index": "custom-design",
"_type": "cars",
"_id": "porche232",
"_score": 1.2413527,
"_source": {
"clientID": "ps1233443",
"customisation": "yes",
"userType": "heavy",
"totalBilling": 3000
}
}
}

如您所见,两个文档都被索引并且具有不同的ID,但是内容相同。在索引了重复文档之后是否可以检测并消除重复的文档?

最佳答案

理想情况下,您需要在每个文档中创建哈希。
但是,由于现在不可能了,请诉诸脚本来做到这一点。

curl -XGET 'http://localhost:9200/Index/IndexType/_search?pretty=true' -d '{
"size": 0,
"aggs": {
"duplicateCount": "terms": {
"script": "doc['clientID'].value + doc['customisation'].value+doc['userType'].value+doc['totalBilling'].value",
"min_doc_count": 2
},
"aggs": {
"duplicateDocuments": {
"top_hits": {}
}
}
}
}'

如果查看结果,则可以在此处看到重复的文档。
现在找到重复的ID并进行批量删除。

您可以在此处详细了解这些方法- https://qbox.io/blog/minimizing-document-duplication-in-elasticsearch

关于elasticsearch - 如何在elasticsearch中删除以前索引的文档?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34783101/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com