Open andrey-vyatkin opened 8 years ago
_< I'll investigate this weekend
Hi, @dewshick
It works as expected, since your change_all
may overwrite previous inserted values so it returns less than 55 results.
To avoid loss in update, you can, for example, store all values in an array:
corpus.each_with_index { |str, id| trie.change_all(:suffix, str) {|arr| arr ||= []; arr << str } }
trie.search_with_prefix(str).flat_map{|_, ids| ids}.uniq.size #=> 55
@luikore Great! Thanks for info! The code was adopted (without thinking too much, my fault) from fulltext search example, maybe it'll be reasonable to write the full text search example same way?
@dewshick good point, I will change the example
ruby 2.0.0, triez 1.0.4
each word in corpus contains
str
string, but only 53 out of 55 results are returned during prefix search