Class: JayAPI::Elasticsearch::Indexes

Inherits:
Object
  • Object
show all
Includes:
Indexable
Defined in:
lib/jay_api/elasticsearch/indexes.rb

Overview

Represents a group of Elasticsearch indexes. Allows the execution of searches over all of the specified indexes or push data to all of them at the same time.

Constant Summary

Constants included from Indexable

JayAPI::Elasticsearch::Indexable::DEFAULT_DOC_TYPE, JayAPI::Elasticsearch::Indexable::SUPPORTED_TYPES

Instance Attribute Summary collapse

Attributes included from Indexable

#batch_size, #client

Instance Method Summary collapse

Methods included from Indexable

#delete_by_query, #delete_by_query_async, #flush, #index, #push, #queue_size, #search

Constructor Details

#initialize(client:, index_names:, batch_size: 100, logger: nil) ⇒ Indexes

Returns a new instance of Indexes.

Parameters:

  • client (JayAPI::Elasticsearch::Client)

    The Elasticsearch Client object.

  • index_names (Array<String>)

    The names of the Elasticsearch indexes.

  • batch_size (Integer) (defaults to: 100)

    The size of the batch. When this many items are pushed into the indexes they are flushed to the Elasticsearch instance.

  • logger (Logging::Logger, nil) (defaults to: nil)

    The logger object to use, if none is given a new one will be created.



20
21
22
23
24
25
26
27
28
29
# File 'lib/jay_api/elasticsearch/indexes.rb', line 20

def initialize(client:, index_names:, batch_size: 100, logger: nil)
  super

  return if (batch_size % index_names.size).zero?

  self.logger.warn(
    "'batch_size' is not a multiple of the number of elements in 'index_names'. " \
    "This can lead to a _bulk size slightly bigger than 'batch_size'"
  )
end

Instance Attribute Details

#index_namesObject (readonly)

Returns the value of attribute index_names.



31
32
33
# File 'lib/jay_api/elasticsearch/indexes.rb', line 31

def index_names
  @index_names
end