Class: JayAPI::Elasticsearch::Indices::Settings

Inherits:
Object
  • Object
show all
Defined in:
lib/jay_api/elasticsearch/indices/settings.rb,
lib/jay_api/elasticsearch/indices/settings/blocks.rb

Overview

Represents the settings of an Elasticsearch Index.

Defined Under Namespace

Classes: Blocks

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(transport_client, index_name) ⇒ Settings

Returns a new instance of Settings.

Parameters:

  • transport_client (Elasticsearch::Transport::Client)

    Elasticsearch’s transport client.

  • index_name (String)

    The name of the index this class will be handling settings for.



16
17
18
19
# File 'lib/jay_api/elasticsearch/indices/settings.rb', line 16

def initialize(transport_client, index_name)
  @transport_client = transport_client
  @index_name = index_name
end

Instance Attribute Details

#index_nameObject (readonly)

Returns the value of attribute index_name.



10
11
12
# File 'lib/jay_api/elasticsearch/indices/settings.rb', line 10

def index_name
  @index_name
end

#transport_clientObject (readonly)

Returns the value of attribute transport_client.



10
11
12
# File 'lib/jay_api/elasticsearch/indices/settings.rb', line 10

def transport_client
  @transport_client
end

Instance Method Details

#allHash

Returns A Hash with all the settings for the index. It looks like this:

{

"number_of_shards" => "5",
"blocks" => { "read_only_allow_delete" => "false", "write" => "false" },
"provided_name" => "xyz01_tests",
"creation_date" => "1588701800423",
"number_of_replicas" => "1",
"uuid" => "VFx2e5t0Qgi-1zc2PUkYEg",
"version" => { "created" => "7010199", "upgraded" => "7100299"}

}.

Returns:

  • (Hash)

    A Hash with all the settings for the index. It looks like this:

    {

    "number_of_shards" => "5",
    "blocks" => { "read_only_allow_delete" => "false", "write" => "false" },
    "provided_name" => "xyz01_tests",
    "creation_date" => "1588701800423",
    "number_of_replicas" => "1",
    "uuid" => "VFx2e5t0Qgi-1zc2PUkYEg",
    "version" => { "created" => "7010199", "upgraded" => "7100299"}
    

    }

Raises:

  • (Elasticsearch::Transport::Transport::Errors::ServerError)

    If an error occurs when trying to get the index’s settings.

  • (KeyError)

    If any of the expected hierarchical elements in the response are missing.



38
39
40
41
# File 'lib/jay_api/elasticsearch/indices/settings.rb', line 38

def all
  transport_client.indices.get_settings(index: index_name)
                  .fetch(index_name).fetch('settings').fetch('index')
end

#blocksJayAPI::Elasticsearch::Indices::Settings::Blocks

Returns The blocks settings for the given index.

Returns:



45
46
47
# File 'lib/jay_api/elasticsearch/indices/settings.rb', line 45

def blocks
  @blocks ||= ::JayAPI::Elasticsearch::Indices::Settings::Blocks.new(self)
end