Skip to content

Commit

Permalink
utf8 characters bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
smix committed Jan 10, 2011
1 parent 46408e1 commit ce793c5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/mongoid_search/keywords_extractor.rb
@@ -1,6 +1,6 @@
class KeywordsExtractor
def self.extract(text)
return [] if text.blank?
text.mb_chars.normalize(:kd).to_s.gsub(/[^\x00-\x7F]/,'').downcase.split(/[\s\.\-_:;'",]+/)
text.mb_chars.normalize(:kd).to_s.gsub(/[^[:alpha:]\s\.\-_:;'",]/,'').downcase.split(/[\s\.\-_:;'",]+/)
end
end
11 changes: 6 additions & 5 deletions lib/mongoid_search/mongoid_search.rb
Expand Up @@ -51,12 +51,13 @@ def search_relevant(query, options={})
scope_stack.inject{|a, b| a + b}.selector
end

limit = options.delete(:limit)
options.delete(:limit)
options.delete(:skip)
options.merge! :scope => {:keywords => keywords}, :query => query
cursor = collection.map_reduce(map, reduce, options).find.sort(['value', -1])
cursor = cursor.limit(limit) if limit
cursor

res = collection.map_reduce(map, reduce, options)

res.find.sort(['value', -1]) # Cursor
end
end

Expand Down

0 comments on commit ce793c5

Please sign in to comment.