Skip to content

Commit

Permalink
Added readme entry for :allow_empty_search option
Browse files Browse the repository at this point in the history
  • Loading branch information
mauriciozaffari committed Dec 7, 2010
1 parent d5175e8 commit bc0899c
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions README.md
Expand Up @@ -24,8 +24,9 @@ Examples
field :name

references_many :tags
refereced_in :category
search_in :brand, :name, :tags => :name
search_in :brand, :name, :tags => :name, :category => :name
end

class Tag
Expand All @@ -34,6 +35,13 @@ Examples

referenced_in :product
end

class Category
include Mongoid::Document
field :name

references_many :products
end

Now when you save a product, you get a _keywords field automatically:

Expand All @@ -58,10 +66,10 @@ Note that the search is case insensitive, and accept partial searching too:
Options
-------

:match:
match:
:any - match any occurrence
:all - match all ocurrences
Default is :any.
Default is _:any_.

search_in :brand, :name, { :tags => :name }, { :match => :any }

Expand All @@ -72,3 +80,13 @@ Options

Product.search("apple motorola").size
=> 0

allow_empty_search:
true - match any occurrence
false - match all ocurrences
Default is _false_.

search_in :brand, :name, { :tags => :name }, { :allow_empty_search => true }

Product.search("").size
=> 1

0 comments on commit bc0899c

Please sign in to comment.