Command Methods

Sections

Aliasing Indices

alias

api.alias(client, indices, alias=None, remove=False)

Helper method called by the CLI.

Parameters:
  • client – The Elasticsearch client connection
  • indices – A list of indices to act on
  • alias – Alias name to operate on.
  • remove – If true, remove the alias.
Return type:

bool

add_to_alias

api.add_to_alias(client, index_name, alias=None)

Add indicated index to the specified alias.

Parameters:
  • client – The Elasticsearch client connection
  • index_name – The index name
  • alias – Alias name to operate on.
Return type:

bool

remove_from_alias

api.remove_from_alias(client, index_name, alias=None)

Remove the indicated index from the specified alias.

Parameters:
  • client – The Elasticsearch client connection
  • index_name – The index name
  • alias – Alias name to operate on.
Return type:

bool

Index Routing Allocation

allocation

api.allocation(client, indices, rule=None, allocation_type='require')

Helper method called by the CLI.

Parameters:
  • client – The Elasticsearch client connection
  • indices – A list of indices to act on
  • rule – The routing allocation rule to apply, e.g. tag=ssd. Must be in the format of key=value, and should match values declared on the correlating nodes in your cluster.
  • allocation_type – Type of allocation to apply
Return type:

bool

apply_allocation_rule

api.apply_allocation_rule(client, indices, rule=None, allocation_type='require')

Apply a required allocation rule to a list of indices.

Parameters:
  • client – The Elasticsearch client connection
  • indices – A list of indices to act on
  • rule – The routing allocation rule to apply, e.g. tag=ssd. Must be in the format of key=value, and should match values declared on the correlating nodes in your cluster.
  • allocation_type – Type of allocation to apply
Return type:

bool

Disabling Bloom Filters

bloom

api.bloom(client, indices, delay=None)

Helper method called by the CLI.

Parameters:
  • client – The Elasticsearch client connection
  • indices – A list of indices to act on
  • delay – Pause n seconds after operating on each index
Return type:

bool

disable_bloom_filter

api.disable_bloom_filter(client, indices, delay=None)

Disable the bloom filter cache for the list of indices. This method will ignore closed indices.

Parameters:
  • client – The Elasticsearch client connection
  • indices – A list of indices to act on
  • delay – Pause n seconds after operating on each index
Return type:

bool

loop_bloom

api.loop_bloom(client, indices, delay)

Iterate over list of indices. Only called from within curator.api.disable_bloom_filter()

Parameters:
  • client – The Elasticsearch client connection
  • indices – A list of indices to act on
  • delay – Pause n seconds after operating on each index
Return type:

bool

Closing Indices

close

api.close(client, indices)

Helper method called by the CLI.

Parameters:
  • client – The Elasticsearch client connection
  • indices – A list of indices to act on
Return type:

bool

close_indices

api.close_indices(client, indices)

Close the indicated indices. Perform a flush (a synced flush, if your Elasticsearch version supports it) before closing. This method will ignore unavailable (including closed) indices.

Parameters:
  • client – The Elasticsearch client connection
  • indices – A list of indices to act on
Return type:

bool

Deleting Indices

delete

api.delete(client, indices, master_timeout=30000)

Helper method called by the CLI. Tries up to 3x to delete indices.

Parameters:
  • client – The Elasticsearch client connection
  • indices – A list of indices to act on
  • master_timeout – Number of milliseconds to wait for master node response
Rtype bool:

delete_indices

api.delete_indices(client, indices, master_timeout=30000)

Delete the indicated indices, including closed indices.

Parameters:
  • client – The Elasticsearch client connection
  • indices – A list of indices to act on
  • master_timeout – Number of milliseconds to wait for master node response
Rtype bool:

Opening Indices

opener

api.opener(client, indices)

Helper method called by the CLI.

Parameters:
  • client – The Elasticsearch client connection
  • indices – A list of indices to act on
Return type:

bool

open_indices

api.open_indices(client, indices)

Open the indicated indices.

Parameters:
  • client – The Elasticsearch client connection
  • indices – A list of indices to act on
Return type:

bool

Optimizing Indices

optimize

api.optimize(client, indices, max_num_segments=None, delay=0, request_timeout=21600)

Helper method called by the CLI.

Parameters:
  • client – The Elasticsearch client connection
  • indices – A list of indices to act on
  • max_num_segments – Merge to this number of segments per shard.
  • delay – A number of seconds to delay after successfully optimizing
  • request_timeout – Number of seconds before the connection should timeout
Return type:

bool

optimize_index

api.optimize_index(client, index_name, max_num_segments=None, delay=0, request_timeout=21600)

Optimize (Lucene forceMerge) index to max_num_segments per shard

Parameters:
  • client – The Elasticsearch client connection
  • index_name – The index name
  • max_num_segments – Merge to this number of segments per shard.
  • delay – A number of seconds to delay after successfully optimizing
  • request_timeout – Number of seconds before the connection should timeout
Return type:

bool

Changing Index Replica Count

replicas

api.replicas(client, indices, replicas=None)

Helper method called by the CLI.

Parameters:
  • client – The Elasticsearch client connection
  • indices – A list of indices to act on
  • replicas – The number of replicas the indices should have
Return type:

bool

change_replicas

api.change_replicas(client, indices, replicas=None)

Change the number of replicas, more or less, for the indicated indices.

Parameters:
  • client – The Elasticsearch client connection
  • indices – A list of indices to act on
  • replicas – The number of replicas the indices should have
Return type:

bool

Sealing (Synced Flush) Indices

seal

api.seal(client, indices)

Helper method called by the CLI.

Parameters:
  • client – The Elasticsearch client connection
  • indices – A list of indices to act on
Return type:

bool

seal_indices

api.seal_indices(client, indices)

Seal the indicated indices (perform a synced flush) if your Elasticsearch version supports it before closing. This method will ignore unavailable (including closed) indices.

Parameters:
  • client – The Elasticsearch client connection
  • indices – A list of indices to act on
Return type:

bool

Show Indices

show

api.show(client, object_list, type=None)

Helper method called by the CLI.

Parameters:
  • client – The Elasticsearch client connection
  • object_list – A list of indices or snapshots to show
  • object_typeindices or snapshots
Return type:

bool

Snapshot Indices

create_snapshot

api.create_snapshot(client, indices='_all', name=None, prefix='curator-', repository='', ignore_unavailable=False, include_global_state=True, partial=False, wait_for_completion=True, request_timeout=21600, skip_repo_validation=False)

Create a snapshot of provided indices (or _all) that are open.

Parameters:
  • client – The Elasticsearch client connection
  • indices – A list of indices to snapshot. Default is _all
  • name – What to name the snapshot. prefix + datestamp if omitted.
  • prefix – Override the default with this value. Defaults to curator-
  • repository – The Elasticsearch snapshot repository to use
  • wait_for_completion (bool) – Wait (or not) for the operation to complete before returning. (default: True)
  • ignore_unavailable (bool) – Ignore unavailable shards/indices. (default: False)
  • include_global_state (bool) – Store cluster global state with snapshot. (default: True)
  • partial (bool) – Do not fail if primary shard is unavailable. (default: False)
  • skip_repo_validation (bool) – Do not validate write access to repository on all cluster nodes before proceeding. (default: False). Useful for shared filesystems where intermittent timeouts can affect validation, but won’t likely affect snapshot success.
Rtype bool:

delete_snapshot

api.delete_snapshot(client, snapshot=None, repository=None)

Delete a single snapshot from a given repository by name

Parameters:
  • client – The Elasticsearch client connection
  • snapshot – The snapshot name
  • repository – The Elasticsearch snapshot repository to use