Class: Elasticated::IndexSelector

Inherits:
Object
  • Object
show all
Includes:
BlockEvaluation
Defined in:
lib/elasticated/index_selector.rb

Instance Method Summary collapse

Methods included from BlockEvaluation

#evaluate

Instance Method Details

#index_for_document(document) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/elasticated/index_selector.rb', line 18

def index_for_document(document)
  params = strategy_params_for_document document
  indices = strategy.call params
  raise "Only one index can be affected for a document indexation" if indices.count > 1
  raise "At least one index should be affected for a document indexation" if indices.count < 1
  indices.first
end

#indices_for_query(query) ⇒ Object



11
12
13
14
15
16
# File 'lib/elasticated/index_selector.rb', line 11

def indices_for_query(query)
  strategy_params = strategy_params_for_query query
  indices = strategy.call strategy_params
  raise "At least one index should be affected for a search" if indices.count < 1
  indices
end