gpt4 book ai didi

elasticsearch - ElasticSearch过滤的查询未返回预期/期望分数结果

转载 作者:行者123 更新时间:2023-12-02 22:32:55 25 4
gpt4 key购买 nike

查询iPad Mini 3 64GB AT&T时,ElasticSeach没有返回期望的结果

ElasticSearch得分最高的是iPad Mini 2 64GB AT&T,iPad Mini 3 64GB AT&T在结果中排​​名第五。

这是BrandAndDeviceName的映射部分:

"BrandAndDeviceName": {
"type": "string",
"fields": {
"autocomplete": {
"type": "string",
"analyzer": "autocomplete"
}
}
},

和REST通话
GET /devices/device/_search/
{
"query": {
"filtered": {
"query": {
"query_string": {
"query": "iPad Mini 3 64GB AT&T",
"default_field": "BrandAndDeviceName.autocomplete"
}
},
"filter": {
"and": [
{
"term": {
"Active": true
}
}
]
}
}
},
"size": 12,
"from": 0
}

这是最高的结果
{
"_index": "devices",
"_type": "device",
"_id": "94698082-d5cb-4f54-829e-dc62e196c894",
"_score": 9.904099,
"_source": {
"DeviceId": "94698082-d5cb-4f54-829e-dc62e196c894",
"DeviceName": "iPad Mini 2 64GB AT&T",
"Active": true,
"Brand": {
"Id": "7d04b58b-3f2d-4f63-821f-7f081d7f1bd9",
"Name": "Apple"
},
"Category": {
"CategoryId": "41d45e60-9587-4dd9-828f-5dacf02a499f",
"CategoryName": "Tablets"
},
"DeviceGroup": {
"Id": "b362318d-5c24-4dd9-a371-3261c6b38ac6",
"Name": "iPad Mini 2"
},
"BrandAndDeviceName": "Apple iPad Mini 2 64GB AT&T"
}
},

请注意,iPad Mini 2 64GB AT&T的最高得分为9.904099,预期文档为第五张,得分为9.483598。
{
"_index": "devices",
"_type": "device",
"_id": "5dd038b7-1dea-491d-8d69-fb349970b8a2",
"_score": 9.483598,
"_source": {
"DeviceId": "5dd038b7-1dea-491d-8d69-fb349970b8a2",
"DeviceName": "iPad Mini 3 64GB AT&T",
"Active": true,
"Brand": {
"Id": "7d04b58b-3f2d-4f63-821f-7f081d7f1bd9",
"Name": "Apple"
},
"Category": {
"CategoryId": "41d45e60-9587-4dd9-828f-5dacf02a499f",
"CategoryName": "Tablets"
},
"BrandAndDeviceName": "Apple iPad Mini 3 64GB AT&T"
}
},

为什么Apple iPad Mini 2 64GB AT&T比Apple iPad Mini 3 64GB AT&T得分更高?

最佳答案

过滤查询不计分;他们只是通过/失败。

Filters are usually faster than queries because they don’t have to calculate the relevance _score for each document —  the answer is just a boolean “Yes, the document matches the filter” or “No, the document does not match the filter”.



http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-filtered-query.html

如果要获得评分结果,只需使用查询而不是过滤器即可。
GET /devices/device/_search/
{
"query": {
"query_string": {
"query": "iPad Mini 3 64GB AT&T",
"default_field": "BrandAndDeviceName.autocomplete"
}
},
"filter": {
"and": [
{
"term": {
"Active": true
}
}
]
},
"size": 12,
"from": 0
}

关于elasticsearch - ElasticSearch过滤的查询未返回预期/期望分数结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28905435/

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