gpt4 book ai didi

elasticsearch - 在Elasticsearch中提升结果

转载 作者:行者123 更新时间:2023-12-02 23:54:14 25 4
gpt4 key购买 nike

我在文档中搜索了一种方法,以在特定字段具有特定值的情况下提升ElasticSearch结果,但是我没有找到任何好的做法,例如,如果某个用户搜索某个查询,我就有一个住在巴黎的用户,希望与巴黎相关的文档出现在第一个或即将被提升。

最佳答案

这有很多,但是您想研究“增强”。这可以在mapping levelquery level处完成。

映射示例:

{
"mappings": {
"_doc": {
"properties": {
"location": {
"type": "keyword",
"boost": 2 <--- 2x boost to the final score
}
}
}
}
}

查询示例:
GET /_search
{
"query": {
"bool": {
"must": {
"match": {
"content": {
"query": "full text search",
"operator": "and"
}
}
},
"should": [
{ "term": {
"location": {
"value": "xxx",
"boost": 3 <--- 3x boost if the location matches
}
}}
]
}
}
}

关于elasticsearch - 在Elasticsearch中提升结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55025702/

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