【问题标题】:elasticsearch nGram/edgengram partial match?elasticsearch nGram/edgengram 部分匹配?
【发布时间】:2012-06-13 14:44:51
【问题描述】:

我正在尝试使部分搜索工作,搜索

“sw” “瑞典” “瑞典

应该匹配“瑞典”

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

Rails Code

我正在使用 this code 来自轮胎仓库作为模板代码。

整个单词仍然匹配!

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

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-3 lucene elasticsearch tire


    【解决方案1】:

    我不是 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”吗? 因为你对该字段的查询也被分析了

    【讨论】:

      【解决方案2】:

      使用edgengram token filter。这会让你得到你想要的。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-11-26
        • 2015-07-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-03-17
        • 2017-02-16
        • 1970-01-01
        相关资源
        最近更新 更多