gpt4 book ai didi

ruby-on-rails - elasticsearch nGram/edgengram 部分匹配?

转载 作者:行者123 更新时间:2023-12-02 23:06:13 29 4
gpt4 key购买 nike

我正在尝试制作 部分搜索 工作,寻找

“sw”
“瑞典”
“瑞典”

应该匹配“瑞典”

我环顾四周,就是无法让它工作

Rails Code

我正在使用
this code从轮胎 repo 作为模板代码。

整个单词仍然匹配!

我已经重新索引并尝试使用 edgengram 过滤器。

最佳答案

我不是 Ruby 开发人员,但发现这篇文章很有用:
http://dev.af83.com/2012/01/19/autocomplete-with-tire.html

就像它说的:

Most databases handle that feature with a filter (with LIKE keyword in SQL, regular expression search with mongoDB). The strategy is simple: iterate on all results and keep only words which match the filter. This is brutal and hurts the hard drive. Elastic Search can do it too, with the prefix query.

With a small index, it plays well. For large indexes it will be more slow and painful.

你说:
whole words still match!

你期望什么? “Sweden”不应该匹配“Sweden”而只能匹配“Swe”、“Swed”或Swede”吗?
因为你在字段上的查询也被分析了

关于ruby-on-rails - elasticsearch nGram/edgengram 部分匹配?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11017407/

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