gpt4 book ai didi

Elasticsearch:具有多个搜索词的 multi_match phrase_prefix 查询

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

我有一个包含条目的数据库

title: This is my awesome title
abstract: A more detailed descriptions of what [...]

我想构建一个与上述文档相匹配的 Elasticsearch 查询,例如,

awe detai

在单词中:具有多个搜索词的 multi_match phrase_prefix 查询。 (这旨在用作“键入时搜索”功能。)

我知道如何组合使用 multi_match 和 phrase_prefix,但我不清楚如何针对多个搜索词执行此操作。

有什么提示吗?

最佳答案

好吧,有几种方法可以做到这一点

POST stack/autocomplete/1
{
"title": "This is my awesome title",
"abstract": "A more detailed descriptions of what"
}

然后您可以使用带星号的查询字符串进行搜索,但这里的问题是您需要在查询中附加星号

POST stack/autocomplete/_search
{
"query": {
"query_string": {
"fields": [
"title",
"abstract"
],
"query": "awe* detai*"
}
}
}

如果你想匹配用户查询那么你可以这样使用

POST stack/autocomplete/_search
{
"query": {
"multi_match": {
"fields": [
"title",
"abstract"
],
"query": "awesome tit",
"type": "phrase_prefix"
}
}
}

要考虑的另一种选择是使用 nGram带有查询字符串,因此您无需修改​​用户查询“awe* detai*”

关于Elasticsearch:具有多个搜索词的 multi_match phrase_prefix 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35584338/

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