gpt4 book ai didi

elasticsearch - 使用双引号搜索关键字以在elasticsearch中获得完全匹配

转载 作者:行者123 更新时间:2023-11-29 02:48:16 24 4
gpt4 key购买 nike

如果用户通过在关键字周围加上引号进行搜索,例如“flowers and mulch”,则应显示完全匹配项。

我尝试使用 query_string,它几乎可以工作,但对这些结果不满意。

谁能帮帮我。

{
"query": {
"query_string": {
"fields": ["body"],
"query": "\"flowers and mulch\""
}
}
}

最佳答案

您应该使用 phrase_match 来精确匹配短语:

{
"query": {
"match_phrase": {
"body": "flowers and mulch"
}
}
}

Phrase matching

In the same way that the match query is the “go-to” query for standard full text search, the match_phrase query is the one you should reach for when you want to find words that are near to each other.

http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/phrase-matching.html

关于elasticsearch - 使用双引号搜索关键字以在elasticsearch中获得完全匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24795822/

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