Class: Elasticity::MultiSearch
- Inherits:
-
Object
- Object
- Elasticity::MultiSearch
- Defined in:
- lib/elasticity/multi_search.rb
Instance Method Summary collapse
- #[](name) ⇒ Object
- #add(name, search, documents: nil, active_records: nil) ⇒ Object
-
#initialize {|_self| ... } ⇒ MultiSearch
constructor
A new instance of MultiSearch.
Constructor Details
#initialize {|_self| ... } ⇒ MultiSearch
Returns a new instance of MultiSearch.
3 4 5 6 7 |
# File 'lib/elasticity/multi_search.rb', line 3 def initialize @searches = {} @mappers = {} yield self if block_given? end |
Instance Method Details
#[](name) ⇒ Object
25 26 27 28 |
# File 'lib/elasticity/multi_search.rb', line 25 def [](name) @results ||= fetch @results[name] end |
#add(name, search, documents: nil, active_records: nil) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/elasticity/multi_search.rb', line 9 def add(name, search, documents: nil, active_records: nil) if !documents.nil? && !active_records.nil? raise ArgumentError, "you can only pass either :documents or :active_records as an option" elsif documents.nil? && active_records.nil? raise ArgumentError, "you need to provide either :documents or :active_records as an option" end @searches[name] = { search_definition: search.search_definition, documents: documents, active_records: active_records } name end |