1

部分検索を機能させようとしています。

「sw」「swe」「swed

「スウェーデン」と一致する必要があります

私は周りを見回しましたが、それを機能させることができません

Railsコード

Tireリポジトリのこのコードをテンプレートコードとして使用し ています。

単語全体はまだ一致しています!

インデックスを再作成し、edgengramフィルターを使用してみました。

4

2 に答える 2

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!

そして、あなたは何を期待していますか?Is "Sweden" は "Sweden" ではなく、"Swe"、"Swed"、または Swede" のみに一致するはずですか? フィールドに対するクエリも分析されるためです。

于 2012-07-03T01:54:49.550 に答える
1

edgengram トークン フィルターを使用します。それはあなたが探しているものを手に入れるでしょう。

于 2013-04-26T19:53:48.493 に答える