Module: Mongoid::Search::ClassMethods
- Defined in:
- lib/mongoid_search/mongoid_search.rb
Overview
:nodoc:
Instance Method Summary collapse
- #full_text_search(query, options = {}) ⇒ Object (also: #csearch, #search)
-
#index_keywords! ⇒ Object
Goes through all documents in the class that includes Mongoid::Search and indexes the keywords.
-
#search_in(*args) ⇒ Object
Set a field or a number of fields as sources for search.
Instance Method Details
#full_text_search(query, options = {}) ⇒ Object Also known as: csearch, search
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/mongoid_search/mongoid_search.rb', line 27 def full_text_search(query, = {}) = () attr_accessor :relevance if [:relevant_search].eql? true return ([:allow_empty_search] ? criteria.all : []) if query.blank? if [:relevant_search] search_relevant(query, ) else search_without_relevance(query, ) end end |
#index_keywords! ⇒ Object
Goes through all documents in the class that includes Mongoid::Search and indexes the keywords.
46 47 48 |
# File 'lib/mongoid_search/mongoid_search.rb', line 46 def index_keywords! all.each { |d| d.index_keywords! ? Log.green('.') : Log.red('F') } end |
#search_in(*args) ⇒ Object
Set a field or a number of fields as sources for search
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/mongoid_search/mongoid_search.rb', line 16 def search_in(*args) args, = (args) set_search_fields([:index], args) field [:index], type: Array index({ [:index] => 1 }, background: true) before_save :set_keywords end |