2012-06-13 113 views

回答

1

我不是一個Ruby developper但發現這篇文章很有用: 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! 

而且你能指望什麼? 「瑞典」不應該與「瑞典」相匹配,而只能是「Swe」,「Swed」或瑞典人「? 因爲您對該字段的查詢也被分析過