class Elasticsearch::Model::Multimodel

Wraps a collection of models when querying multiple indices

@see Elasticsearch::Model.search

Attributes

models[R]

Public Class Methods

new(*models) click to toggle source

@param models [Class] The list of models across which the search will be performed

# File lib/elasticsearch/model/multimodel.rb, line 70
def initialize(*models)
  @models = models.flatten
  @models = Model::Registry.all if @models.empty?
end

Public Instance Methods

client() click to toggle source

Get the client common for all models

@return Elasticsearch::Transport::Client

# File lib/elasticsearch/model/multimodel.rb, line 95
def client
  Elasticsearch::Model.client
end
document_type() click to toggle source

Get an Array of document types used for retrieving documents when doing a search across multiple models

@return [Array] the list of document types used for retrieving documents

# File lib/elasticsearch/model/multimodel.rb, line 87
def document_type
  models.map { |m| m.document_type }.compact.presence
end
index_name() click to toggle source

Get an Array of index names used for retrieving documents when doing a search across multiple models

@return [Array] the list of index names used for retrieving documents

# File lib/elasticsearch/model/multimodel.rb, line 79
def index_name
  models.map { |m| m.index_name }
end