Class: Elasticated::IndexSelector
- Inherits:
-
Object
- Object
- Elasticated::IndexSelector
- Includes:
- BlockEvaluation
- Defined in:
- lib/elasticated/index_selector.rb
Instance Attribute Summary collapse
-
#delimiters ⇒ Object
readonly
Returns the value of attribute delimiters.
-
#strategy ⇒ Object
readonly
Returns the value of attribute strategy.
Instance Method Summary collapse
- #index_for_document(document) ⇒ Object
- #index_for_percolator(query) ⇒ Object
- #indices_for_query(query, opts = {}) ⇒ Object
-
#initialize(strategy = nil, delimiters = nil) ⇒ IndexSelector
constructor
params will not be optionals in the next version.
Methods included from BlockEvaluation
Constructor Details
#initialize(strategy = nil, delimiters = nil) ⇒ IndexSelector
params will not be optionals in the next version
11 12 13 14 |
# File 'lib/elasticated/index_selector.rb', line 11 def initialize(strategy=nil, delimiters=nil) @strategy = strategy @delimiters = delimiters end |
Instance Attribute Details
#delimiters ⇒ Object (readonly)
Returns the value of attribute delimiters.
8 9 10 |
# File 'lib/elasticated/index_selector.rb', line 8 def delimiters @delimiters end |
#strategy ⇒ Object (readonly)
Returns the value of attribute strategy.
8 9 10 |
# File 'lib/elasticated/index_selector.rb', line 8 def strategy @strategy end |
Instance Method Details
#index_for_document(document) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/elasticated/index_selector.rb', line 23 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 |
#index_for_percolator(query) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/elasticated/index_selector.rb', line 31 def index_for_percolator(query) params = strategy_params_for_percolator query indices = strategy.call params raise "Only one index can be affected for a percolator indexation" if indices.count > 1 raise "At least one index should be affected for a percolator indexation" if indices.count < 1 indices.first end |
#indices_for_query(query, opts = {}) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/elasticated/index_selector.rb', line 16 def indices_for_query(query, opts={}) strategy_params = Elasticated.strategy_params_for_query_service.strategy_params_for_query delimiters, query, opts indices = strategy.call strategy_params raise "At least one index should be affected for a search" if indices.count < 1 indices end |