Railsthinking_sphinx模糊搜索问题
我正在尝试为自动建议搜索字段设置thinking_sphinx。每次按键时,我都会对数据库中字段中当前文本值进行 sphinx 搜索。我将 min_infix_len 设置为 3,我不希望在至少输入 3 个字符之前开始出现建议。问题来自于多词查询。尽管设置 :match_mode => :短语,我输入的每个新单词显然在 sphinx 搜索中被视为单独的关键字,必须遵守 min_infix_len 3。
因此,如果我输入“Lorem Ipsum”,我会得到“Lor”的自动建议, “Lore”和“Lorem”。然后我没有得到“Lorem I”和“Lorem Ip”的结果。然后,一旦我点击“Lorem Ips”,我就会再次得到结果。
这是怎么回事?如果这不是:match_mode => : 这句话是为了,那么它是为了什么呢?
I'm trying to set up thinking_sphinx for an auto-suggestion search field. On each keypress I do a sphinx search on my database of the current text value in the field. I set min_infix_len to 3, I don't want suggestions to start appearing until at least 3 characters are typed. The problem comes with multiple-word queries. Despite setting :match_mode => :phrase, each new word I type is apparently treated as a separate keyword in the sphinx search, having to abide to the min_infix_len of 3.
So if I'm typing "Lorem Ipsum", I get auto-suggestions for "Lor", "Lore", and "Lorem". Then I get no results for "Lorem I" and "Lorem Ip". Then once I hit "Lorem Ips" I get results again.
What's the deal? If this isn't what :match_mode => :phrase is for, then what is it for?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过此方法扩展 String 类,该方法将一个或多个单词的字符串转换为可星号搜索的字符串
You could extend the String class by this method which converts a string of one or more words to a star-searchable string
我非常确定 min_infix_len 仅在 Sphinx 中索引数据时才会产生影响。它在搜索时根本不适用。因此: min_infix_len 适用于每个单词,而不适用于短语。
I'm pretty certain min_infix_len is only has an impact when indexing data in Sphinx. It doesn't apply at all when searching. So: min_infix_len applies for each word, not for phrases.