Module: Mongoid::Search
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/mongoid_search/mongoid_search.rb,
lib/mongoid_search/railtie.rb,
lib/mongoid_search.rb
Defined Under Namespace
Modules: ClassMethods Classes: Railtie
Constant Summary collapse
- @@match =
:any- @@allow_empty_search =
false- @@relevant_search =
false- @@stem_keywords =
false- @@stem_proc =
proc { |word| word.stem }
- @@ignore_list =
[]
- @@regex_search =
true- @@regex =
Match partial words on both sides (slower)
proc { |query| /#{query}/ }
- @@ligatures =
{ 'œ' => 'oe', 'æ' => 'ae', 'ꜵ' => 'ao' }
- @@minimum_word_size =
2- @@strip_symbols =
/[._:;'"`,?|+={}()!@#%^&*<>~$\-\\\/\[\]]/- @@strip_accents =
/[^\s\p{Alnum}]/
Class Method Summary collapse
Instance Method Summary collapse
-
#allow_empty_search ⇒ Object
If true, an empty search will return all objects.
- #get_keywords(fields) ⇒ Object
-
#ignore_list ⇒ Object
Words to ignore.
- #index_keywords! ⇒ Object
-
#match ⇒ Object
Default matching type.
-
#regex ⇒ Object
Regex to search.
-
#regex_search ⇒ Object
Search using regex (slower).
-
#relevant_search ⇒ Object
If true, will search with relevance information.
- #set_keywords ⇒ Object
-
#stem_keywords ⇒ Object
Stem keywords.
-
#stem_proc ⇒ Object
Stem procedure.
Class Method Details
.classes ⇒ Object
12 13 14 |
# File 'lib/mongoid_search/mongoid_search.rb', line 12 def self.classes @@classes end |
.setup {|_self| ... } ⇒ Object
69 70 71 |
# File 'lib/mongoid_search.rb', line 69 def self.setup yield self end |
Instance Method Details
#allow_empty_search ⇒ Object
If true, an empty search will return all objects
13 |
# File 'lib/mongoid_search.rb', line 13 mattr_accessor :allow_empty_search |
#get_keywords(fields) ⇒ Object
147 148 149 150 |
# File 'lib/mongoid_search/mongoid_search.rb', line 147 def get_keywords(fields) Mongoid::Search::Util.keywords(self, fields) .flatten.reject { |k| k.nil? || k.empty? }.uniq.sort end |
#ignore_list ⇒ Object
Words to ignore
29 |
# File 'lib/mongoid_search.rb', line 29 mattr_accessor :ignore_list |
#index_keywords! ⇒ Object
135 136 137 138 139 |
# File 'lib/mongoid_search/mongoid_search.rb', line 135 def index_keywords! search_fields.map do |index, fields| update_attribute(index, get_keywords(fields)) end end |
#match ⇒ Object
Default matching type. Match :any or :all searched keywords
9 |
# File 'lib/mongoid_search.rb', line 9 mattr_accessor :match |
#regex ⇒ Object
Regex to search
43 |
# File 'lib/mongoid_search.rb', line 43 mattr_accessor :regex |
#regex_search ⇒ Object
Search using regex (slower)
39 |
# File 'lib/mongoid_search.rb', line 39 mattr_accessor :regex_search |
#relevant_search ⇒ Object
If true, will search with relevance information
17 |
# File 'lib/mongoid_search.rb', line 17 mattr_accessor :relevant_search |
#set_keywords ⇒ Object
141 142 143 144 145 |
# File 'lib/mongoid_search/mongoid_search.rb', line 141 def set_keywords search_fields.each do |index, fields| send("#{index}=", get_keywords(fields)) end end |
#stem_keywords ⇒ Object
Stem keywords
21 |
# File 'lib/mongoid_search.rb', line 21 mattr_accessor :stem_keywords |
#stem_proc ⇒ Object
Stem procedure
25 |
# File 'lib/mongoid_search.rb', line 25 mattr_accessor :stem_proc |