gpt4 book ai didi

ElasticSearch 使用分页重复结果

转载 作者:行者123 更新时间:2023-11-29 02:46:30 25 4
gpt4 key购买 nike

我将 elasticsearch 与 pyes 一起使用。我在最后一页的结果中得到了重复项。这是我的查询:

"query": {
"query": {
"filtered": {
"filter": {
"and": [
{
"match_all": {

}
}
]
},
"query": {
"bool": {
"minimum_number_should_match": 1,
"should": [
{
"text": {
"name.keyword_name": {
"operator": "and",
"query": "kentucky",
"type": "boolean",
"fuzziness": 0.8
}
}
},
{
"text": {
"address": {
"operator": "and",
"query": "kentucky",
"type": "boolean"
}
}
},
{
"text": {
"neighborhoods.name": {
"operator": "and",
"query": "kentucky",
"type": "boolean",
"fuzziness": 0.8
}
}
},
{
"text": {
"categories.name": {
"operator": "and",
"query": "kentucky",
"type": "boolean",
"fuzziness": 0.8
}
}
}
]
}
}
}
},
"facets": {
"neighborhoods.id": {
"terms": {
"field": "neighborhoods.id",
"size": 10
}
},
"categories.id": {
"terms": {
"field": "categories.id",
"size": 10
}
}
},
"size": 15,
"from": 15,
"fields": [
"id",
"categories.id",
"name",
"address",
"city",
"state",
"zipcode",
"location",
"_id",
"pos_review_count",
"neg_review_count",
"wishlist_count",
"recommender_count",
"checkin_count"
]
},

在这个查询中,我有

    "size": 15,
"from": 15,

对于此特定查询,返回的对象总数为 24。“from”为 15,total_count 为 24,我希望返回 9 个结果。但是相反,因为我将“大小”设置为 15,所以我得到了 15 个结果条目。由于只剩下 9 个唯一结果,因此 6 个文档被显示两次。知道如何让我得到 9 个结果而不是 15 个重复的结果吗?

感谢您的帮助!

最佳答案

如果你有多个分片上的数据,它可能会返回多次,我不知道为什么。抱歉,这不是很具体,因为我不知道为什么会这样。

尝试使用首选项:http://www.elastic.co/guide/en/elasticsearch/reference/1.4/search-request-preference.html

我们使用首选项自定义字符串,它解决了我们的重复数据问题。

您的复制设置是什么?数据是否可能在多个分片上?您使用的是什么版本?

不幸的是,对于 pyes,您无法在多搜索调用中指定首选项。尝试在搜索调用中将首选项指定为查询参数。

搜索(索引=...,.....,偏好=)

关于ElasticSearch 使用分页重复结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10836142/

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