gpt4 book ai didi

elasticsearch - 模糊搜索词组/多个术语

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

我需要对词组进行模糊搜索(而不仅仅是单个术语)。

我的数据库表有很多字符串,包含 1 个或多个单词,我需要找到最适合搜索的一组单词。

例如:

我搜索"pommes de terre",它应该给出"pomme de terre",并且带有低分、“pomme”“terre” 或任何可能的匹配词。

对于单个术语,它可以完美地工作,并纠正打字错误和严重错误。但是如果我搜索很多词,单个词比完全匹配和词组有更好的分数:

搜索:“pomme de terre”

  • poire,分数:2.3862941
  • pomme,得分:2.2527628
  • pomme de terre,得分:1.1263814 <- 不够高

问题

Is there a solution which gives a better score the more terms matches ? (the more fuzzy terms matches, the more score is high)

设置

搜索查询:

{query: 
{fuzzy_like_this:
{ like_text: 'pomme de terre'}
}
}

设置:

:analysis => {
:analyzer => {
:folding => {
:tokenizer => "icu_tokenizer",
:filter => [ "icu_folding"]
}
}
}

我是初学者,使用 elasticsearch-rails。我尝试使用建议查询,但它们不能用于 rails gem。

我必须明确指出,此搜索是我项目的重要组成部分...

最佳答案

我遇到了同样的问题。以下是我使用 Java-8 和 ES-1.7 修复它的方法。

QueryBuilders.multiMatchQuery("pommes de terre","name")
.fuzziness(3)
.minimumShouldMatch("90%")
.type(Type.MOST_FIELDS);

注意:minimumShouldMatch 是这里的诀窍。

关于elasticsearch - 模糊搜索词组/多个术语,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26285228/

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