Class: Elasticsearch::Model::Multimodel
- Inherits:
-
Object
- Object
- Elasticsearch::Model::Multimodel
- Defined in:
- lib/elasticsearch/model/multimodel.rb
Overview
Wraps a collection of models when querying multiple indices
Instance Attribute Summary collapse
-
#models ⇒ Object
readonly
Returns the value of attribute models.
Instance Method Summary collapse
-
#client ⇒ Object
Get the client common for all models.
-
#document_type ⇒ Array
Get an Array of document types used for retrieving documents when doing a search across multiple models.
-
#index_name ⇒ Array
Get an Array of index names used for retrieving documents when doing a search across multiple models.
-
#initialize(*models) ⇒ Multimodel
constructor
A new instance of Multimodel.
Constructor Details
#initialize(*models) ⇒ Multimodel
Returns a new instance of Multimodel.
53 54 55 56 |
# File 'lib/elasticsearch/model/multimodel.rb', line 53 def initialize(*models) @models = models.flatten @models = Model::Registry.all if @models.empty? end |
Instance Attribute Details
#models ⇒ Object (readonly)
Returns the value of attribute models.
49 50 51 |
# File 'lib/elasticsearch/model/multimodel.rb', line 49 def models @models end |
Instance Method Details
#client ⇒ Object
Get the client common for all models
78 79 80 |
# File 'lib/elasticsearch/model/multimodel.rb', line 78 def client Elasticsearch::Model.client end |
#document_type ⇒ Array
Get an Array of document types used for retrieving documents when doing a search across multiple models
70 71 72 |
# File 'lib/elasticsearch/model/multimodel.rb', line 70 def document_type models.map { |m| m.document_type } end |
#index_name ⇒ Array
Get an Array of index names used for retrieving documents when doing a search across multiple models
62 63 64 |
# File 'lib/elasticsearch/model/multimodel.rb', line 62 def index_name models.map { |m| m.index_name } end |