lib/mongoid_fulltext.rb in mongoid_fulltext-0.5.5 vs lib/mongoid_fulltext.rb in mongoid_fulltext-0.5.6
- old
+ new
@@ -22,11 +22,11 @@
index_name = 'mongoid_fulltext.index_%s_%s' % [self.name.downcase, self.mongoid_fulltext_config.count]
end
config = {
:alphabet => 'abcdefghijklmnopqrstuvwxyz0123456789 ',
- :word_separators => "- \n\t",
+ :word_separators => "-_ \n\t",
:ngram_width => 3,
:max_ngrams_to_search => 6,
:apply_prefix_scoring_to_all_words => true,
:index_full_words => true,
:index_short_prefixes => false,
@@ -187,11 +187,11 @@
if config[:remove_accents]
str = UnicodeUtils.nfkd(CGI.unescape(str)).gsub(/[^\x00-\x7F]/,'')
end
- # Remove any characters that aren't in the alphabet
- filtered_str = str.mb_chars.to_s.downcase.split('').find_all{ |ch| config[:alphabet][ch] }.join('')
+ # Remove any characters that aren't in the alphabet and aren't word separators
+ filtered_str = str.mb_chars.to_s.downcase.split('').find_all{ |ch| config[:alphabet][ch] or config[:word_separators][ch] }.join('')
# Figure out how many ngrams to extract from the string. If we can't afford to extract all ngrams,
# step over the string in evenly spaced strides to extract ngrams. For example, to extract 3 3-letter
# ngrams from 'abcdefghijk', we'd want to extract 'abc', 'efg', and 'ijk'.
if bound_number_returned