lib/mongoid_search/util.rb in mongoid_search-0.3.3 vs lib/mongoid_search/util.rb in mongoid_search-0.3.4

- old
+ new

@@ -32,18 +32,20 @@ def self.normalize_keywords(text) ligatures = Mongoid::Search.ligatures ignore_list = Mongoid::Search.ignore_list stem_keywords = Mongoid::Search.stem_keywords stem_proc = Mongoid::Search.stem_proc + strip_symbols = Mongoid::Search.strip_symbols + strip_accents = Mongoid::Search.strip_accents return [] if text.blank? text = text.to_s. mb_chars. normalize(:kd). downcase. to_s. - gsub(/[._:;'"`,?|+={}()!@#%^&*<>~\$\-\\\/\[\]]/, ' '). # strip punctuation - gsub(/[^\s\p{Alnum}]/,''). # strip accents + gsub(strip_symbols, ' '). # strip symbols + gsub(strip_accents, ''). # strip accents gsub(/[#{ligatures.keys.join("")}]/) {|c| ligatures[c]}. split(' '). reject { |word| word.size < Mongoid::Search.minimum_word_size } text = text.reject { |word| ignore_list.include?(word) } unless ignore_list.blank? text = text.map(&stem_proc) if stem_keywords