Purpose
Enable search over fields.
Usage
Installation
Add to your Gemfile:
gem 'mongoid_matcher'
And run:
bundle install
Add to model
class SomeModel
include Mongoid::Document
include Mongoid::Matcher
end
Example searches
Returns model objects where field value is exactly the same:
SomeModel.matching('search string') # searches from all fields exact match
SomeModel.matching('search string', :fields => [:name, :desc])
SomeModel.matching('search string, :types => [Array, String])
Regexp:
SomeModel.matching(/^search string$/) # Regexp search for exact match
SomeModel.matching(/search string/) # Regexp search for containing
# Read more: http://www.ruby-doc.org/core-1.9.3/Regexp.html