API Documentation

All the API calls map the raw REST api as closely as possible, including the distinction between required and optional arguments to the calls. This means that the code makes distinction between positional and keyword arguments; we, however, recommend that people use keyword arguments for all calls for consistency and safety.

Note

for compatibility with the Python ecosystem we use from_ instead of from and doc_type instead of type as parameter names.

Global options

Some parameters are added by the client itself and can be used in all API calls.

Ignore

An API call is considered successful (and will return a response) if elasticsearch returns a 2XX response. Otherwise an instance of TransportError (or a more specific subclass) will be raised. You can see other exception and error states in Exceptions. If you do not wish an exception to be raised you can always pass in an ignore parameter with either a single status code that should be ignored or a list of them:

from elasticsearch import Elasticsearch
es = Elasticsearch()

# ignore 400 cause by IndexAlreadyExistsException when creating an index
es.indices.create(index='test-index', ignore=400)

# ignore 404 and 400
es.indices.delete(index='test-index', ignore=[400, 404])

Timeout

Global timeout can be set when constructing the client (see Connection‘s timeout parameter) or on a per-request basis using request_timeout (float value in seconds) as part of any API call, this value will get passed to the perform_request method of the connection class:

# only wait for 1 second, regardless of the client's default
es.cluster.health(wait_for_status='yellow', request_timeout=1)

Note

Some API calls also accept a timeout parameter that is passed to Elasticsearch server. This timeout is internal and doesn’t guarantee that the request will end in the specified time.

Response Filtering

The filter_path parameter is used to reduce the response returned by elasticsearch. For example, to only return _id and _type, do:

es.search(index='test-index', filter_path=['hits.hits._id', 'hits.hits._type'])

It also supports the * wildcard character to match any field or part of a field’s name:

es.search(index='test-index', filter_path=['hits.hits._*'])

Elasticsearch

class elasticsearch.Elasticsearch(hosts=None, transport_class=<class 'elasticsearch.transport.Transport'>, **kwargs)

Elasticsearch low-level client. Provides a straightforward mapping from Python to ES REST endpoints.

The instance has attributes cat, cluster, indices, ingest, nodes, snapshot and tasks that provide access to instances of CatClient, ClusterClient, IndicesClient, IngestClient, NodesClient, SnapshotClient and TasksClient respectively. This is the preferred (and only supported) way to get access to those classes and their methods.

You can specify your own connection class which should be used by providing the connection_class parameter:

# create connection to localhost using the ThriftConnection
es = Elasticsearch(connection_class=ThriftConnection)

If you want to turn on Sniffing you have several options (described in Transport):

# create connection that will automatically inspect the cluster to get
# the list of active nodes. Start with nodes running on 'esnode1' and
# 'esnode2'
es = Elasticsearch(
    ['esnode1', 'esnode2'],
    # sniff before doing anything
    sniff_on_start=True,
    # refresh nodes after a node fails to respond
    sniff_on_connection_fail=True,
    # and also every 60 seconds
    sniffer_timeout=60
)

Different hosts can have different parameters, use a dictionary per node to specify those:

# connect to localhost directly and another node using SSL on port 443
# and an url_prefix. Note that ``port`` needs to be an int.
es = Elasticsearch([
    {'host': 'localhost'},
    {'host': 'othernode', 'port': 443, 'url_prefix': 'es', 'use_ssl': True},
])

If using SSL, there are several parameters that control how we deal with certificates (see Urllib3HttpConnection for detailed description of the options):

es = Elasticsearch(
    ['localhost:443', 'other_host:443'],
    # turn on SSL
    use_ssl=True,
    # make sure we verify SSL certificates (off by default)
    verify_certs=True,
    # provide a path to CA certs on disk
    ca_certs='/path/to/CA_certs'
)

SSL client authentication is supported (see Urllib3HttpConnection for detailed description of the options):

es = Elasticsearch(
    ['localhost:443', 'other_host:443'],
    # turn on SSL
    use_ssl=True,
    # make sure we verify SSL certificates (off by default)
    verify_certs=True,
    # provide a path to CA certs on disk
    ca_certs='/path/to/CA_certs',
    # PEM formatted SSL client certificate
    client_cert='/path/to/clientcert.pem',
    # PEM formatted SSL client key
    client_key='/path/to/clientkey.pem'
)

Alternatively you can use RFC-1738 formatted URLs, as long as they are not in conflict with other options:

es = Elasticsearch(
    [
        'http://user:secret@localhost:9200/',
        'https://user:secret@other_host:443/production'
    ],
    verify_certs=True
)
Parameters:
  • hosts – list of nodes we should connect to. Node should be a dictionary ({“host”: “localhost”, “port”: 9200}), the entire dictionary will be passed to the Connection class as kwargs, or a string in the format of host[:port] which will be translated to a dictionary automatically. If no value is given the Urllib3HttpConnection class defaults will be used.
  • transport_classTransport subclass to use.
  • kwargs – any additional arguments will be passed on to the Transport class and, subsequently, to the Connection instances.
bulk(*args, **kwargs)

Perform many index/delete operations in a single API call.

See the bulk() helper function for a more friendly API. http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html

Parameters:
  • body – The operation definition and data (action-data pairs), separated by newlines
  • index – Default index for items which don’t provide one
  • doc_type – Default document type for items which don’t provide one
  • _source – True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub- request
  • _source_exclude – Default list of fields to exclude from the returned _source field, can be overridden on each sub-request
  • _source_include – Default list of fields to extract and return from the _source field, can be overridden on each sub-request
  • fields – Default comma-separated list of fields to return in the response for updates, can be overridden on each sub-request
  • pipeline – The pipeline id to preprocess incoming documents with
  • refresh – If true then refresh the effected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false (the default) then do nothing with refreshes., valid choices are: ‘true’, ‘false’, ‘wait_for’
  • routing – Specific routing value
  • timeout – Explicit operation timeout
  • wait_for_active_shards – Sets the number of shard copies that must be active before proceeding with the bulk operation. Defaults to 1, meaning the primary shard only. Set to all for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
clear_scroll(*args, **kwargs)

Clear the scroll request created by specifying the scroll parameter to search. http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html

Parameters:
  • scroll_id – A comma-separated list of scroll IDs to clear
  • body – A comma-separated list of scroll IDs to clear if none was specified via the scroll_id parameter
count(*args, **kwargs)

Execute a query and get the number of matches for that query. http://www.elastic.co/guide/en/elasticsearch/reference/current/search-count.html

Parameters:
  • index – A comma-separated list of indices to restrict the results
  • doc_type – A comma-separated list of types to restrict the results
  • body – A query to restrict the results specified with the Query DSL (optional)
  • allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
  • analyze_wildcard – Specify whether wildcard and prefix queries should be analyzed (default: false)
  • analyzer – The analyzer to use for the query string
  • default_operator – The default operator for query string query (AND or OR), default ‘OR’, valid choices are: ‘AND’, ‘OR’
  • df – The field to use as default where no field prefix is given in the query string
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • lenient – Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
  • min_score – Include only documents with a specific _score value in the result
  • preference – Specify the node or shard the operation should be performed on (default: random)
  • q – Query in the Lucene query string syntax
  • routing – Specific routing value
create(*args, **kwargs)

Adds a typed JSON document in a specific index, making it searchable. Behind the scenes this method calls index(..., op_type=’create’) http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html

Parameters:
  • index – The name of the index
  • doc_type – The type of the document
  • id – Document ID
  • body – The document
  • parent – ID of the parent document
  • pipeline – The pipeline id to preprocess incoming documents with
  • refresh – If true then refresh the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false (the default) then do nothing with refreshes., valid choices are: ‘true’, ‘false’, ‘wait_for’
  • routing – Specific routing value
  • timeout – Explicit operation timeout
  • timestamp – Explicit timestamp for the document
  • ttl – Expiration time for the document
  • version – Explicit version number for concurrency control
  • version_type – Specific version type, valid choices are: ‘internal’, ‘external’, ‘external_gte’, ‘force’
  • wait_for_active_shards – Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to all for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
delete(*args, **kwargs)

Delete a typed JSON document from a specific index based on its id. http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete.html

Parameters:
  • index – The name of the index
  • doc_type – The type of the document
  • id – The document ID
  • parent – ID of parent document
  • refresh – If true then refresh the effected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false (the default) then do nothing with refreshes., valid choices are: ‘true’, ‘false’, ‘wait_for’
  • routing – Specific routing value
  • timeout – Explicit operation timeout
  • version – Explicit version number for concurrency control
  • version_type – Specific version type, valid choices are: ‘internal’, ‘external’, ‘external_gte’, ‘force’
  • wait_for_active_shards – Sets the number of shard copies that must be active before proceeding with the delete operation. Defaults to 1, meaning the primary shard only. Set to all for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
delete_by_query(*args, **kwargs)

Delete all documents matching a query. https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html

Parameters:
  • index – A comma-separated list of index names to search; use _all or empty string to perform the operation on all indices
  • body – The search definition using the Query DSL
  • doc_type – A comma-separated list of document types to search; leave empty to perform the operation on all types
  • _source – True or false to return the _source field or not, or a list of fields to return
  • _source_exclude – A list of fields to exclude from the returned _source field
  • _source_include – A list of fields to extract and return from the _source field
  • allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
  • analyze_wildcard – Specify whether wildcard and prefix queries should be analyzed (default: false)
  • analyzer – The analyzer to use for the query string
  • conflicts – What to do when the delete-by-query hits version conflicts?, default ‘abort’, valid choices are: ‘abort’, ‘proceed’
  • default_operator – The default operator for query string query (AND or OR), default ‘OR’, valid choices are: ‘AND’, ‘OR’
  • df – The field to use as default where no field prefix is given in the query string
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
  • from_ – Starting offset (default: 0)
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • lenient – Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
  • preference – Specify the node or shard the operation should be performed on (default: random)
  • q – Query in the Lucene query string syntax
  • refresh – Should the effected indexes be refreshed?
  • request_cache – Specify if request cache should be used for this request or not, defaults to index level setting
  • requests_per_second – The throttle for this request in sub-requests per second. -1 means no throttle., default 0
  • routing – A comma-separated list of specific routing values
  • scroll – Specify how long a consistent view of the index should be maintained for scrolled search
  • scroll_size – Size on the scroll request powering the update_by_query
  • search_timeout – Explicit timeout for each search request. Defaults to no timeout.
  • search_type – Search operation type, valid choices are: ‘query_then_fetch’, ‘dfs_query_then_fetch’
  • size – Number of hits to return (default: 10)
  • slices – The number of slices this task should be divided into. Defaults to 1 meaning the task isn’t sliced into subtasks., default 1
  • sort – A comma-separated list of <field>:<direction> pairs
  • stats – Specific ‘tag’ of the request for logging and statistical purposes
  • terminate_after – The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
  • timeout – Time each individual bulk request should wait for shards that are unavailable., default ‘1m’
  • version – Specify whether to return document version as part of a hit
  • wait_for_active_shards – Sets the number of shard copies that must be active before proceeding with the delete by query operation. Defaults to 1, meaning the primary shard only. Set to all for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
  • wait_for_completion – Should the request should block until the delete-by-query is complete., default True
delete_script(*args, **kwargs)

Remove a stored script from elasticsearch. http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html

Parameters:id – Script ID
exists(*args, **kwargs)

Returns a boolean indicating whether or not given document exists in Elasticsearch. http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html

Parameters:
  • index – The name of the index
  • doc_type – The type of the document (use _all to fetch the first document matching the ID across all types)
  • id – The document ID
  • _source – True or false to return the _source field or not, or a list of fields to return
  • _source_exclude – A list of fields to exclude from the returned _source field
  • _source_include – A list of fields to extract and return from the _source field
  • parent – The ID of the parent document
  • preference – Specify the node or shard the operation should be performed on (default: random)
  • realtime – Specify whether to perform the operation in realtime or search mode
  • refresh – Refresh the shard containing the document before performing the operation
  • routing – Specific routing value
  • stored_fields – A comma-separated list of stored fields to return in the response
  • version – Explicit version number for concurrency control
  • version_type – Specific version type, valid choices are: ‘internal’, ‘external’, ‘external_gte’, ‘force’
exists_source(*args, **kwargs)

http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html

Parameters:
  • index – The name of the index
  • doc_type – The type of the document; use _all to fetch the first document matching the ID across all types
  • id – The document ID
  • _source – True or false to return the _source field or not, or a list of fields to return
  • _source_exclude – A list of fields to exclude from the returned _source field
  • _source_include – A list of fields to extract and return from the _source field
  • parent – The ID of the parent document
  • preference – Specify the node or shard the operation should be performed on (default: random)
  • realtime – Specify whether to perform the operation in realtime or search mode
  • refresh – Refresh the shard containing the document before performing the operation
  • routing – Specific routing value
  • version – Explicit version number for concurrency control
  • version_type – Specific version type, valid choices are: ‘internal’, ‘external’, ‘external_gte’, ‘force’
explain(*args, **kwargs)

The explain api computes a score explanation for a query and a specific document. This can give useful feedback whether a document matches or didn’t match a specific query. http://www.elastic.co/guide/en/elasticsearch/reference/current/search-explain.html

Parameters:
  • index – The name of the index
  • doc_type – The type of the document
  • id – The document ID
  • body – The query definition using the Query DSL
  • _source – True or false to return the _source field or not, or a list of fields to return
  • _source_exclude – A list of fields to exclude from the returned _source field
  • _source_include – A list of fields to extract and return from the _source field
  • analyze_wildcard – Specify whether wildcards and prefix queries in the query string query should be analyzed (default: false)
  • analyzer – The analyzer for the query string query
  • default_operator – The default operator for query string query (AND or OR), default ‘OR’, valid choices are: ‘AND’, ‘OR’
  • df – The default field for query string query (default: _all)
  • lenient – Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
  • parent – The ID of the parent document
  • preference – Specify the node or shard the operation should be performed on (default: random)
  • q – Query in the Lucene query string syntax
  • routing – Specific routing value
  • stored_fields – A comma-separated list of stored fields to return in the response
field_caps(*args, **kwargs)

The field capabilities API allows to retrieve the capabilities of fields among multiple indices. http://www.elastic.co/guide/en/elasticsearch/reference/current/search-field-caps.html

Parameters:
  • index – A comma-separated list of index names; use _all or empty string to perform the operation on all indices
  • body – Field json objects containing an array of field names
  • allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
  • fields – A comma-separated list of field names
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
get(*args, **kwargs)

Get a typed JSON document from the index based on its id. http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html

Parameters:
  • index – The name of the index
  • doc_type – The type of the document (use _all to fetch the first document matching the ID across all types)
  • id – The document ID
  • _source – True or false to return the _source field or not, or a list of fields to return
  • _source_exclude – A list of fields to exclude from the returned _source field
  • _source_include – A list of fields to extract and return from the _source field
  • parent – The ID of the parent document
  • preference – Specify the node or shard the operation should be performed on (default: random)
  • realtime – Specify whether to perform the operation in realtime or search mode
  • refresh – Refresh the shard containing the document before performing the operation
  • routing – Specific routing value
  • stored_fields – A comma-separated list of stored fields to return in the response
  • version – Explicit version number for concurrency control
  • version_type – Specific version type, valid choices are: ‘internal’, ‘external’, ‘external_gte’, ‘force’
get_script(*args, **kwargs)

Retrieve a script from the API. http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html

Parameters:id – Script ID
get_source(*args, **kwargs)

Get the source of a document by it’s index, type and id. http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html

Parameters:
  • index – The name of the index
  • doc_type – The type of the document; use _all to fetch the first document matching the ID across all types
  • id – The document ID
  • _source – True or false to return the _source field or not, or a list of fields to return
  • _source_exclude – A list of fields to exclude from the returned _source field
  • _source_include – A list of fields to extract and return from the _source field
  • parent – The ID of the parent document
  • preference – Specify the node or shard the operation should be performed on (default: random)
  • realtime – Specify whether to perform the operation in realtime or search mode
  • refresh – Refresh the shard containing the document before performing the operation
  • routing – Specific routing value
  • version – Explicit version number for concurrency control
  • version_type – Specific version type, valid choices are: ‘internal’, ‘external’, ‘external_gte’, ‘force’
get_template(*args, **kwargs)

Retrieve a search template. http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html

Parameters:id – Template ID
index(*args, **kwargs)

Adds or updates a typed JSON document in a specific index, making it searchable. http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html

Parameters:
  • index – The name of the index
  • doc_type – The type of the document
  • body – The document
  • id – Document ID
  • op_type – Explicit operation type, default ‘index’, valid choices are: ‘index’, ‘create’
  • parent – ID of the parent document
  • pipeline – The pipeline id to preprocess incoming documents with
  • refresh – If true then refresh the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false (the default) then do nothing with refreshes., valid choices are: ‘true’, ‘false’, ‘wait_for’
  • routing – Specific routing value
  • timeout – Explicit operation timeout
  • timestamp – Explicit timestamp for the document
  • ttl – Expiration time for the document
  • version – Explicit version number for concurrency control
  • version_type – Specific version type, valid choices are: ‘internal’, ‘external’, ‘external_gte’, ‘force’
  • wait_for_active_shards – Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to all for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
info(*args, **kwargs)

Get the basic info from the current cluster. http://www.elastic.co/guide/

mget(*args, **kwargs)

Get multiple documents based on an index, type (optional) and ids. http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.html

Parameters:
  • body – Document identifiers; can be either docs (containing full document information) or ids (when index and type is provided in the URL.
  • index – The name of the index
  • doc_type – The type of the document
  • _source – True or false to return the _source field or not, or a list of fields to return
  • _source_exclude – A list of fields to exclude from the returned _source field
  • _source_include – A list of fields to extract and return from the _source field
  • preference – Specify the node or shard the operation should be performed on (default: random)
  • realtime – Specify whether to perform the operation in realtime or search mode
  • refresh – Refresh the shard containing the document before performing the operation
  • routing – Specific routing value
  • stored_fields – A comma-separated list of stored fields to return in the response
msearch(*args, **kwargs)

Execute several search requests within the same API. http://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html

Parameters:
  • body – The request definitions (metadata-search request definition pairs), separated by newlines
  • index – A comma-separated list of index names to use as default
  • doc_type – A comma-separated list of document types to use as default
  • max_concurrent_searches – Controls the maximum number of concurrent searches the multi search api will execute
  • pre_filter_shard_size – A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on it’s rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint., default 128
  • search_type – Search operation type, valid choices are: ‘query_then_fetch’, ‘query_and_fetch’, ‘dfs_query_then_fetch’, ‘dfs_query_and_fetch’
  • typed_keys – Specify whether aggregation and suggester names should be prefixed by their respective types in the response
msearch_template(*args, **kwargs)

The /_search/template endpoint allows to use the mustache language to pre render search requests, before they are executed and fill existing templates with template parameters. http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html

Parameters:
  • body – The request definitions (metadata-search request definition pairs), separated by newlines
  • index – A comma-separated list of index names to use as default
  • doc_type – A comma-separated list of document types to use as default
  • max_concurrent_searches – Controls the maximum number of concurrent searches the multi search api will execute
  • search_type – Search operation type, valid choices are: ‘query_then_fetch’, ‘query_and_fetch’, ‘dfs_query_then_fetch’, ‘dfs_query_and_fetch’
  • typed_keys – Specify whether aggregation and suggester names should be prefixed by their respective types in the response
mtermvectors(*args, **kwargs)

Multi termvectors API allows to get multiple termvectors based on an index, type and id. http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-termvectors.html

Parameters:
  • index – The index in which the document resides.
  • doc_type – The type of the document.
  • body – Define ids, documents, parameters or a list of parameters per document here. You must at least provide a list of document ids. See documentation.
  • field_statistics – Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified in body “params” or “docs”., default True
  • fields – A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body “params” or “docs”.
  • ids – A comma-separated list of documents ids. You must define ids as parameter or set “ids” or “docs” in the request body
  • offsets – Specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body “params” or “docs”., default True
  • parent – Parent id of documents. Applies to all returned documents unless otherwise specified in body “params” or “docs”.
  • payloads – Specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body “params” or “docs”., default True
  • positions – Specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body “params” or “docs”., default True
  • preference – Specify the node or shard the operation should be performed on (default: random) .Applies to all returned documents unless otherwise specified in body “params” or “docs”.
  • realtime – Specifies if requests are real-time as opposed to near- real-time (default: true).
  • routing – Specific routing value. Applies to all returned documents unless otherwise specified in body “params” or “docs”.
  • term_statistics – Specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body “params” or “docs”., default False
  • version – Explicit version number for concurrency control
  • version_type – Specific version type, valid choices are: ‘internal’, ‘external’, ‘external_gte’, ‘force’
ping(*args, **kwargs)

Returns True if the cluster is up, False otherwise. http://www.elastic.co/guide/

put_script(*args, **kwargs)

Create a script in given language with specified ID. http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html

Parameters:
  • id – Script ID
  • body – The document
put_template(*args, **kwargs)

Create a search template. http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html

Parameters:
  • id – Template ID
  • body – The document
reindex(*args, **kwargs)

Reindex all documents from one index to another. https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html

Parameters:
  • body – The search definition using the Query DSL and the prototype for the index request.
  • refresh – Should the effected indexes be refreshed?
  • requests_per_second – The throttle to set on this request in sub- requests per second. -1 means no throttle., default 0
  • slices – The number of slices this task should be divided into. Defaults to 1 meaning the task isn’t sliced into subtasks., default 1
  • timeout – Time each individual bulk request should wait for shards that are unavailable., default ‘1m’
  • wait_for_active_shards – Sets the number of shard copies that must be active before proceeding with the reindex operation. Defaults to 1, meaning the primary shard only. Set to all for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
  • wait_for_completion – Should the request should block until the reindex is complete., default True
reindex_rethrottle(*args, **kwargs)

Change the value of requests_per_second of a running reindex task. https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html

Parameters:
  • task_id – The task id to rethrottle
  • requests_per_second – The throttle to set on this request in floating sub-requests per second. -1 means set no throttle.
render_search_template(*args, **kwargs)

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-template.html

Parameters:
  • id – The id of the stored search template
  • body – The search definition template and its params
scroll(*args, **kwargs)

Scroll a search request created by specifying the scroll parameter. http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html

Parameters:
  • scroll_id – The scroll ID
  • body – The scroll ID if not passed by URL or query parameter.
  • scroll – Specify how long a consistent view of the index should be maintained for scrolled search
search(*args, **kwargs)

Execute a search query and get back search hits that match the query. http://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html

Parameters:
  • index – A comma-separated list of index names to search; use _all or empty string to perform the operation on all indices
  • doc_type – A comma-separated list of document types to search; leave empty to perform the operation on all types
  • body – The search definition using the Query DSL
  • _source – True or false to return the _source field or not, or a list of fields to return
  • _source_exclude – A list of fields to exclude from the returned _source field
  • _source_include – A list of fields to extract and return from the _source field
  • allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
  • analyze_wildcard – Specify whether wildcard and prefix queries should be analyzed (default: false)
  • analyzer – The analyzer to use for the query string
  • batched_reduce_size – The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large., default 512
  • default_operator – The default operator for query string query (AND or OR), default ‘OR’, valid choices are: ‘AND’, ‘OR’
  • df – The field to use as default where no field prefix is given in the query string
  • docvalue_fields – A comma-separated list of fields to return as the docvalue representation of a field for each hit
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
  • explain – Specify whether to return detailed information about score computation as part of a hit
  • from_ – Starting offset (default: 0)
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • lenient – Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
  • max_concurrent_shard_requests – The number of concurrent shard requests this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests, default ‘The default grows with the number of nodes in the cluster but is at most 256.’
  • pre_filter_shard_size – A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on it’s rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint., default 128
  • preference – Specify the node or shard the operation should be performed on (default: random)
  • q – Query in the Lucene query string syntax
  • request_cache – Specify if request cache should be used for this request or not, defaults to index level setting
  • routing – A comma-separated list of specific routing values
  • scroll – Specify how long a consistent view of the index should be maintained for scrolled search
  • search_type – Search operation type, valid choices are: ‘query_then_fetch’, ‘dfs_query_then_fetch’
  • size – Number of hits to return (default: 10)
  • sort – A comma-separated list of <field>:<direction> pairs
  • stats – Specific ‘tag’ of the request for logging and statistical purposes
  • stored_fields – A comma-separated list of stored fields to return as part of a hit
  • suggest_field – Specify which field to use for suggestions
  • suggest_mode – Specify suggest mode, default ‘missing’, valid choices are: ‘missing’, ‘popular’, ‘always’
  • suggest_size – How many suggestions to return in response
  • suggest_text – The source text for which the suggestions should be returned
  • terminate_after – The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
  • timeout – Explicit operation timeout
  • track_scores – Whether to calculate and return scores even if they are not used for sorting
  • track_total_hits – Indicate if the number of documents that match the query should be tracked
  • typed_keys – Specify whether aggregation and suggester names should be prefixed by their respective types in the response
  • version – Specify whether to return document version as part of a hit
search_shards(*args, **kwargs)

The search shards api returns the indices and shards that a search request would be executed against. This can give useful feedback for working out issues or planning optimizations with routing and shard preferences. http://www.elastic.co/guide/en/elasticsearch/reference/current/search-shards.html

Parameters:
  • index – A comma-separated list of index names to search; use _all or empty string to perform the operation on all indices
  • allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • local – Return local information, do not retrieve the state from master node (default: false)
  • preference – Specify the node or shard the operation should be performed on (default: random)
  • routing – Specific routing value
search_template(*args, **kwargs)

A query that accepts a query template and a map of key/value pairs to fill in template parameters. http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html

Parameters:
  • index – A comma-separated list of index names to search; use _all or empty string to perform the operation on all indices
  • doc_type – A comma-separated list of document types to search; leave empty to perform the operation on all types
  • body – The search definition template and its params
  • allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
  • explain – Specify whether to return detailed information about score computation as part of a hit
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • preference – Specify the node or shard the operation should be performed on (default: random)
  • profile – Specify whether to profile the query execution
  • routing – A comma-separated list of specific routing values
  • scroll – Specify how long a consistent view of the index should be maintained for scrolled search
  • search_type – Search operation type, valid choices are: ‘query_then_fetch’, ‘query_and_fetch’, ‘dfs_query_then_fetch’, ‘dfs_query_and_fetch’
  • typed_keys – Specify whether aggregation and suggester names should be prefixed by their respective types in the response
termvectors(*args, **kwargs)

Returns information and statistics on terms in the fields of a particular document. The document could be stored in the index or artificially provided by the user (Added in 1.4). Note that for documents stored in the index, this is a near realtime API as the term vectors are not available until the next refresh. http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-termvectors.html

Parameters:
  • index – The index in which the document resides.
  • doc_type – The type of the document.
  • id – The id of the document, when not specified a doc param should be supplied.
  • body – Define parameters and or supply a document to get termvectors for. See documentation.
  • field_statistics – Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned., default True
  • fields – A comma-separated list of fields to return.
  • offsets – Specifies if term offsets should be returned., default True
  • parent – Parent id of documents.
  • payloads – Specifies if term payloads should be returned., default True
  • positions – Specifies if term positions should be returned., default True
  • preference – Specify the node or shard the operation should be performed on (default: random).
  • realtime – Specifies if request is real-time as opposed to near- real-time (default: true).
  • routing – Specific routing value.
  • term_statistics – Specifies if total term frequency and document frequency should be returned., default False
  • version – Explicit version number for concurrency control
  • version_type – Specific version type, valid choices are: ‘internal’, ‘external’, ‘external_gte’, ‘force’
update(*args, **kwargs)

Update a document based on a script or partial data provided. http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html

Parameters:
  • index – The name of the index
  • doc_type – The type of the document
  • id – Document ID
  • body – The request definition using either script or partial doc
  • _source – True or false to return the _source field or not, or a list of fields to return
  • _source_exclude – A list of fields to exclude from the returned _source field
  • _source_include – A list of fields to extract and return from the _source field
  • fields – A comma-separated list of fields to return in the response
  • lang – The script language (default: painless)
  • parent – ID of the parent document. Is is only used for routing and when for the upsert request
  • refresh – If true then refresh the effected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false (the default) then do nothing with refreshes., valid choices are: ‘true’, ‘false’, ‘wait_for’
  • retry_on_conflict – Specify how many times should the operation be retried when a conflict occurs (default: 0)
  • routing – Specific routing value
  • timeout – Explicit operation timeout
  • timestamp – Explicit timestamp for the document
  • ttl – Expiration time for the document
  • version – Explicit version number for concurrency control
  • version_type – Specific version type, valid choices are: ‘internal’, ‘force’
  • wait_for_active_shards – Sets the number of shard copies that must be active before proceeding with the update operation. Defaults to 1, meaning the primary shard only. Set to all for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
update_by_query(*args, **kwargs)

Perform an update on all documents matching a query. https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html

Parameters:
  • index – A comma-separated list of index names to search; use _all or empty string to perform the operation on all indices
  • doc_type – A comma-separated list of document types to search; leave empty to perform the operation on all types
  • body – The search definition using the Query DSL
  • _source – True or false to return the _source field or not, or a list of fields to return
  • _source_exclude – A list of fields to exclude from the returned _source field
  • _source_include – A list of fields to extract and return from the _source field
  • allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
  • analyze_wildcard – Specify whether wildcard and prefix queries should be analyzed (default: false)
  • analyzer – The analyzer to use for the query string
  • conflicts – What to do when the update by query hits version conflicts?, default ‘abort’, valid choices are: ‘abort’, ‘proceed’
  • default_operator – The default operator for query string query (AND or OR), default ‘OR’, valid choices are: ‘AND’, ‘OR’
  • df – The field to use as default where no field prefix is given in the query string
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
  • from_ – Starting offset (default: 0)
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • lenient – Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
  • pipeline – Ingest pipeline to set on index requests made by this action. (default: none)
  • preference – Specify the node or shard the operation should be performed on (default: random)
  • q – Query in the Lucene query string syntax
  • refresh – Should the effected indexes be refreshed?
  • request_cache – Specify if request cache should be used for this request or not, defaults to index level setting
  • requests_per_second – The throttle to set on this request in sub- requests per second. -1 means no throttle., default 0
  • routing – A comma-separated list of specific routing values
  • scroll – Specify how long a consistent view of the index should be maintained for scrolled search
  • scroll_size – Size on the scroll request powering the update_by_query
  • search_timeout – Explicit timeout for each search request. Defaults to no timeout.
  • search_type – Search operation type, valid choices are: ‘query_then_fetch’, ‘dfs_query_then_fetch’
  • size – Number of hits to return (default: 10)
  • slices – The number of slices this task should be divided into. Defaults to 1 meaning the task isn’t sliced into subtasks., default 1
  • sort – A comma-separated list of <field>:<direction> pairs
  • stats – Specific ‘tag’ of the request for logging and statistical purposes
  • terminate_after – The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
  • timeout – Time each individual bulk request should wait for shards that are unavailable., default ‘1m’
  • version – Specify whether to return document version as part of a hit
  • version_type – Should the document increment the version number (internal) on hit or not (reindex)
  • wait_for_active_shards – Sets the number of shard copies that must be active before proceeding with the update by query operation. Defaults to 1, meaning the primary shard only. Set to all for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
  • wait_for_completion – Should the request should block until the update by query operation is complete., default True

Indices

class elasticsearch.client.IndicesClient(client)
analyze(*args, **kwargs)

Perform the analysis process on a text and return the tokens breakdown of the text. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-analyze.html

Parameters:
  • index – The name of the index to scope the operation
  • body – Define analyzer/tokenizer parameters and the text on which the analysis should be performed
  • format – Format of the output, default ‘detailed’, valid choices are: ‘detailed’, ‘text’
  • prefer_local – With true, specify that a local shard should be used if available, with false, use a random shard (default: true)
clear_cache(*args, **kwargs)

Clear either all caches or specific cached associated with one ore more indices. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-clearcache.html

Parameters:
  • index – A comma-separated list of index name to limit the operation
  • allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
  • field_data – Clear field data
  • fielddata – Clear field data
  • fields – A comma-separated list of fields to clear when using the field_data parameter (default: all)
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • query – Clear query caches
  • recycler – Clear the recycler cache
  • request – Clear request cache
  • request_cache – Clear request cache
close(*args, **kwargs)

Close an index to remove it’s overhead from the cluster. Closed index is blocked for read/write operations. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html

Parameters:
  • index – The name of the index
  • allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • master_timeout – Specify timeout for connection to master
  • timeout – Explicit operation timeout
create(*args, **kwargs)

Create an index in Elasticsearch. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html

Parameters:
  • index – The name of the index
  • body – The configuration for the index (settings and mappings)
  • master_timeout – Specify timeout for connection to master
  • timeout – Explicit operation timeout
  • update_all_types – Whether to update the mapping for all fields with the same name across all types or not
  • wait_for_active_shards – Set the number of active shards to wait for before the operation returns.
delete(*args, **kwargs)

Delete an index in Elasticsearch http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-delete-index.html

Parameters:
  • index – A comma-separated list of indices to delete; use _all or * string to delete all indices
  • allow_no_indices – Ignore if a wildcard expression resolves to no concrete indices (default: false)
  • expand_wildcards – Whether wildcard expressions should get expanded to open or closed indices (default: open), default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
  • ignore_unavailable – Ignore unavailable indexes (default: false)
  • master_timeout – Specify timeout for connection to master
  • timeout – Explicit operation timeout
delete_alias(*args, **kwargs)

Delete specific alias. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html

Parameters:
  • index – A comma-separated list of index names (supports wildcards); use _all for all indices
  • name – A comma-separated list of aliases to delete (supports wildcards); use _all to delete all aliases for the specified indices.
  • master_timeout – Specify timeout for connection to master
  • timeout – Explicit timeout for the operation
delete_template(*args, **kwargs)

Delete an index template by its name. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html

Parameters:
  • name – The name of the template
  • master_timeout – Specify timeout for connection to master
  • timeout – Explicit operation timeout
exists(*args, **kwargs)

Return a boolean indicating whether given index exists. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-exists.html

Parameters:
  • index – A comma-separated list of index names
  • allow_no_indices – Ignore if a wildcard expression resolves to no concrete indices (default: false)
  • expand_wildcards – Whether wildcard expressions should get expanded to open or closed indices (default: open), default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
  • flat_settings – Return settings in flat format (default: false)
  • ignore_unavailable – Ignore unavailable indexes (default: false)
  • include_defaults – Whether to return all default setting for each of the indices., default False
  • local – Return local information, do not retrieve the state from master node (default: false)
exists_alias(*args, **kwargs)

Return a boolean indicating whether given alias exists. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html

Parameters:
  • index – A comma-separated list of index names to filter aliases
  • name – A comma-separated list of alias names to return
  • allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘all’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • local – Return local information, do not retrieve the state from master node (default: false)
exists_template(*args, **kwargs)

Return a boolean indicating whether given template exists. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html

Parameters:
  • name – The comma separated names of the index templates
  • flat_settings – Return settings in flat format (default: false)
  • local – Return local information, do not retrieve the state from master node (default: false)
  • master_timeout – Explicit operation timeout for connection to master node
exists_type(*args, **kwargs)

Check if a type/types exists in an index/indices. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-types-exists.html

Parameters:
  • index – A comma-separated list of index names; use _all to check the types across all indices
  • doc_type – A comma-separated list of document types to check
  • allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • local – Return local information, do not retrieve the state from master node (default: false)
flush(*args, **kwargs)

Explicitly flush one or more indices. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-flush.html

Parameters:
  • index – A comma-separated list of index names; use _all or empty string for all indices
  • allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
  • force – Whether a flush should be forced even if it is not necessarily needed ie. if no changes will be committed to the index. This is useful if transaction log IDs should be incremented even if no uncommitted changes are present. (This setting can be considered as internal)
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • wait_if_ongoing – If set to true the flush operation will block until the flush can be executed if another flush operation is already executing. The default is true. If set to false the flush will be skipped iff if another flush operation is already running.
flush_synced(*args, **kwargs)

Perform a normal flush, then add a generated unique marker (sync_id) to all shards. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-synced-flush.html

Parameters:
  • index – A comma-separated list of index names; use _all or empty string for all indices
  • allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
forcemerge(*args, **kwargs)

The force merge API allows to force merging of one or more indices through an API. The merge relates to the number of segments a Lucene index holds within each shard. The force merge operation allows to reduce the number of segments by merging them.

This call will block until the merge is complete. If the http connection is lost, the request will continue in the background, and any new requests will block until the previous force merge is complete. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-forcemerge.html

Parameters:
  • index – A comma-separated list of index names; use _all or empty string to perform the operation on all indices
  • allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
  • flush – Specify whether the index should be flushed after performing the operation (default: true)
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • max_num_segments – The number of segments the index should be merged into (default: dynamic)
  • only_expunge_deletes – Specify whether the operation should only expunge deleted documents
  • operation_threading – TODO: ?
  • wait_for_merge – Specify whether the request should block until the merge process is finished (default: true)
get(*args, **kwargs)

The get index API allows to retrieve information about one or more indexes. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-index.html

Parameters:
  • index – A comma-separated list of index names
  • allow_no_indices – Ignore if a wildcard expression resolves to no concrete indices (default: false)
  • expand_wildcards – Whether wildcard expressions should get expanded to open or closed indices (default: open), default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
  • flat_settings – Return settings in flat format (default: false)
  • ignore_unavailable – Ignore unavailable indexes (default: false)
  • include_defaults – Whether to return all default setting for each of the indices., default False
  • local – Return local information, do not retrieve the state from master node (default: false)
get_alias(*args, **kwargs)

Retrieve a specified alias. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html

Parameters:
  • index – A comma-separated list of index names to filter aliases
  • name – A comma-separated list of alias names to return
  • allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘all’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • local – Return local information, do not retrieve the state from master node (default: false)
get_field_mapping(*args, **kwargs)

Retrieve mapping definition of a specific field. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-field-mapping.html

Parameters:
  • fields – A comma-separated list of fields
  • index – A comma-separated list of index names
  • doc_type – A comma-separated list of document types
  • allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • include_defaults – Whether the default mapping values should be returned as well
  • local – Return local information, do not retrieve the state from master node (default: false)
get_mapping(*args, **kwargs)

Retrieve mapping definition of index or index/type. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-mapping.html

Parameters:
  • index – A comma-separated list of index names
  • doc_type – A comma-separated list of document types
  • allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • local – Return local information, do not retrieve the state from master node (default: false)
get_settings(*args, **kwargs)

Retrieve settings for one or more (or all) indices. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-settings.html

Parameters:
  • index – A comma-separated list of index names; use _all or empty string to perform the operation on all indices
  • name – The name of the settings that should be included
  • allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default [‘open’, ‘closed’], valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
  • flat_settings – Return settings in flat format (default: false)
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • include_defaults – Whether to return all default setting for each of the indices., default False
  • local – Return local information, do not retrieve the state from master node (default: false)
get_template(*args, **kwargs)

Retrieve an index template by its name. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html

Parameters:
  • name – The name of the template
  • flat_settings – Return settings in flat format (default: false)
  • local – Return local information, do not retrieve the state from master node (default: false)
  • master_timeout – Explicit operation timeout for connection to master node
get_upgrade(*args, **kwargs)

Monitor how much of one or more index is upgraded. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-upgrade.html

Parameters:
  • index – A comma-separated list of index names; use _all or empty string to perform the operation on all indices
  • allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
open(*args, **kwargs)

Open a closed index to make it available for search. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html

Parameters:
  • index – The name of the index
  • allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘closed’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • master_timeout – Specify timeout for connection to master
  • timeout – Explicit operation timeout
put_alias(*args, **kwargs)

Create an alias for a specific index/indices. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html

Parameters:
  • index – A comma-separated list of index names the alias should point to (supports wildcards); use _all to perform the operation on all indices.
  • name – The name of the alias to be created or updated
  • body – The settings for the alias, such as routing or filter
  • master_timeout – Specify timeout for connection to master
  • timeout – Explicit timeout for the operation
put_mapping(*args, **kwargs)

Register specific mapping definition for a specific type. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html

Parameters:
  • doc_type – The name of the document type
  • body – The mapping definition
  • index – A comma-separated list of index names the mapping should be added to (supports wildcards); use _all or omit to add the mapping on all indices.
  • allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • master_timeout – Specify timeout for connection to master
  • timeout – Explicit operation timeout
  • update_all_types – Whether to update the mapping for all fields with the same name across all types or not
put_settings(*args, **kwargs)

Change specific index level settings in real time. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html

Parameters:
  • body – The index settings to be updated
  • index – A comma-separated list of index names; use _all or empty string to perform the operation on all indices
  • allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
  • flat_settings – Return settings in flat format (default: false)
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • master_timeout – Specify timeout for connection to master
  • preserve_existing – Whether to update existing settings. If set to true existing settings on an index remain unchanged, the default is false
put_template(*args, **kwargs)

Create an index template that will automatically be applied to new indices created. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html

Parameters:
  • name – The name of the template
  • body – The template definition
  • create – Whether the index template should only be added if new or can also replace an existing one, default False
  • flat_settings – Return settings in flat format (default: false)
  • master_timeout – Specify timeout for connection to master
  • order – The order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers)
  • timeout – Explicit operation timeout
recovery(*args, **kwargs)

The indices recovery API provides insight into on-going shard recoveries. Recovery status may be reported for specific indices, or cluster-wide. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-recovery.html

Parameters:
  • index – A comma-separated list of index names; use _all or empty string to perform the operation on all indices
  • active_only – Display only those recoveries that are currently on- going, default False
  • detailed – Whether to display detailed information about shard recovery, default False
refresh(*args, **kwargs)

Explicitly refresh one or more index, making all operations performed since the last refresh available for search. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-refresh.html

Parameters:
  • index – A comma-separated list of index names; use _all or empty string to perform the operation on all indices
  • allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
rollover(*args, **kwargs)

The rollover index API rolls an alias over to a new index when the existing index is considered to be too large or too old.

The API accepts a single alias name and a list of conditions. The alias must point to a single index only. If the index satisfies the specified conditions then a new index is created and the alias is switched to point to the new alias. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-rollover-index.html

Parameters:
  • alias – The name of the alias to rollover
  • new_index – The name of the rollover index
  • body – The conditions that needs to be met for executing rollover
  • dry_run – If set to true the rollover action will only be validated but not actually performed even if a condition matches. The default is false
  • master_timeout – Specify timeout for connection to master
  • timeout – Explicit operation timeout
  • wait_for_active_shards – Set the number of active shards to wait for on the newly created rollover index before the operation returns.
segments(*args, **kwargs)

Provide low level segments information that a Lucene index (shard level) is built with. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-segments.html

Parameters:
  • index – A comma-separated list of index names; use _all or empty string to perform the operation on all indices
  • allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • operation_threading – TODO: ?
  • verbose – Includes detailed memory usage by Lucene., default False
shard_stores(*args, **kwargs)

Provides store information for shard copies of indices. Store information reports on which nodes shard copies exist, the shard copy version, indicating how recent they are, and any exceptions encountered while opening the shard index or from earlier engine failure. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-shards-stores.html

Parameters:
  • index – A comma-separated list of index names; use _all or empty string to perform the operation on all indices
  • allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • operation_threading – TODO: ?
  • status – A comma-separated list of statuses used to filter on shards to get store information for, valid choices are: ‘green’, ‘yellow’, ‘red’, ‘all’
shrink(*args, **kwargs)

The shrink index API allows you to shrink an existing index into a new index with fewer primary shards. The number of primary shards in the target index must be a factor of the shards in the source index. For example an index with 8 primary shards can be shrunk into 4, 2 or 1 primary shards or an index with 15 primary shards can be shrunk into 5, 3 or 1. If the number of shards in the index is a prime number it can only be shrunk into a single primary shard. Before shrinking, a (primary or replica) copy of every shard in the index must be present on the same node. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-shrink-index.html

Parameters:
  • index – The name of the source index to shrink
  • target – The name of the target index to shrink into
  • body – The configuration for the target index (settings and aliases)
  • master_timeout – Specify timeout for connection to master
  • timeout – Explicit operation timeout
  • wait_for_active_shards – Set the number of active shards to wait for on the shrunken index before the operation returns.
stats(*args, **kwargs)

Retrieve statistics on different operations happening on an index. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-stats.html

Parameters:
  • index – A comma-separated list of index names; use _all or empty string to perform the operation on all indices
  • metric – Limit the information returned the specific metrics.
  • completion_fields – A comma-separated list of fields for fielddata and suggest index metric (supports wildcards)
  • fielddata_fields – A comma-separated list of fields for fielddata index metric (supports wildcards)
  • fields – A comma-separated list of fields for fielddata and completion index metric (supports wildcards)
  • groups – A comma-separated list of search groups for search index metric
  • include_segment_file_sizes – Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested), default False
  • level – Return stats aggregated at cluster, index or shard level, default ‘indices’, valid choices are: ‘cluster’, ‘indices’, ‘shards’
  • types – A comma-separated list of document types for the indexing index metric
update_aliases(*args, **kwargs)

Update specified aliases. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html

Parameters:
  • body – The definition of actions to perform
  • master_timeout – Specify timeout for connection to master
  • timeout – Request timeout
upgrade(*args, **kwargs)

Upgrade one or more indices to the latest format through an API. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-upgrade.html

Parameters:
  • index – A comma-separated list of index names; use _all or empty string to perform the operation on all indices
  • allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • only_ancient_segments – If true, only ancient (an older Lucene major release) segments will be upgraded
  • wait_for_completion – Specify whether the request should block until the all segments are upgraded (default: false)
validate_query(*args, **kwargs)

Validate a potentially expensive query without executing it. http://www.elastic.co/guide/en/elasticsearch/reference/current/search-validate.html

Parameters:
  • index – A comma-separated list of index names to restrict the operation; use _all or empty string to perform the operation on all indices
  • doc_type – A comma-separated list of document types to restrict the operation; leave empty to perform the operation on all types
  • body – The query definition specified with the Query DSL
  • all_shards – Execute validation on all shards instead of one random shard per index
  • allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
  • analyze_wildcard – Specify whether wildcard and prefix queries should be analyzed (default: false)
  • analyzer – The analyzer to use for the query string
  • default_operator – The default operator for query string query (AND or OR), default ‘OR’, valid choices are: ‘AND’, ‘OR’
  • df – The field to use as default where no field prefix is given in the query string
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
  • explain – Return detailed information about the error
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • lenient – Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
  • operation_threading – TODO: ?
  • q – Query in the Lucene query string syntax
  • rewrite – Provide a more detailed explanation showing the actual Lucene query that will be executed.

Ingest

class elasticsearch.client.IngestClient(client)
delete_pipeline(*args, **kwargs)

https://www.elastic.co/guide/en/elasticsearch/plugins/current/ingest.html

Parameters:
  • id – Pipeline ID
  • master_timeout – Explicit operation timeout for connection to master node
  • timeout – Explicit operation timeout
get_pipeline(*args, **kwargs)

https://www.elastic.co/guide/en/elasticsearch/plugins/current/ingest.html

Parameters:
  • id – Comma separated list of pipeline ids. Wildcards supported
  • master_timeout – Explicit operation timeout for connection to master node
put_pipeline(*args, **kwargs)

https://www.elastic.co/guide/en/elasticsearch/plugins/current/ingest.html

Parameters:
  • id – Pipeline ID
  • body – The ingest definition
  • master_timeout – Explicit operation timeout for connection to master node
  • timeout – Explicit operation timeout
simulate(*args, **kwargs)

https://www.elastic.co/guide/en/elasticsearch/plugins/current/ingest.html

Parameters:
  • body – The simulate definition
  • id – Pipeline ID
  • verbose – Verbose mode. Display data output for each processor in executed pipeline, default False

Cluster

class elasticsearch.client.ClusterClient(client)
allocation_explain(*args, **kwargs)

http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-allocation-explain.html

Parameters:
  • body – The index, shard, and primary flag to explain. Empty means ‘explain the first unassigned shard’
  • include_disk_info – Return information about disk usage and shard sizes (default: false)
  • include_yes_decisions – Return ‘YES’ decisions in explanation (default: false)
get_settings(*args, **kwargs)

Get cluster settings. http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-update-settings.html

Parameters:
  • flat_settings – Return settings in flat format (default: false)
  • include_defaults – Whether to return all default clusters setting., default False
  • master_timeout – Explicit operation timeout for connection to master node
  • timeout – Explicit operation timeout
health(*args, **kwargs)

Get a very simple status on the health of the cluster. http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html

Parameters:
  • index – Limit the information returned to a specific index
  • level – Specify the level of detail for returned information, default ‘cluster’, valid choices are: ‘cluster’, ‘indices’, ‘shards’
  • local – Return local information, do not retrieve the state from master node (default: false)
  • master_timeout – Explicit operation timeout for connection to master node
  • timeout – Explicit operation timeout
  • wait_for_active_shards – Wait until the specified number of shards is active
  • wait_for_events – Wait until all currently queued events with the given priority are processed, valid choices are: ‘immediate’, ‘urgent’, ‘high’, ‘normal’, ‘low’, ‘languid’
  • wait_for_no_relocating_shards – Whether to wait until there are no relocating shards in the cluster
  • wait_for_nodes – Wait until the specified number of nodes is available
  • wait_for_status – Wait until cluster is in a specific state, default None, valid choices are: ‘green’, ‘yellow’, ‘red’
pending_tasks(*args, **kwargs)

The pending cluster tasks API returns a list of any cluster-level changes (e.g. create index, update mapping, allocate or fail shard) which have not yet been executed. http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-pending.html

Parameters:
  • local – Return local information, do not retrieve the state from master node (default: false)
  • master_timeout – Specify timeout for connection to master
put_settings(*args, **kwargs)

Update cluster wide specific settings. http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-update-settings.html

Parameters:
  • body – The settings to be updated. Can be either transient or persistent (survives cluster restart).
  • flat_settings – Return settings in flat format (default: false)
  • master_timeout – Explicit operation timeout for connection to master node
  • timeout – Explicit operation timeout
reroute(*args, **kwargs)

Explicitly execute a cluster reroute allocation command including specific commands. http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-reroute.html

Parameters:
  • body – The definition of commands to perform (move, cancel, allocate)
  • dry_run – Simulate the operation only and return the resulting state
  • explain – Return an explanation of why the commands can or cannot be executed
  • master_timeout – Explicit operation timeout for connection to master node
  • metric – Limit the information returned to the specified metrics. Defaults to all but metadata, valid choices are: ‘_all’, ‘blocks’, ‘metadata’, ‘nodes’, ‘routing_table’, ‘master_node’, ‘version’
  • retry_failed – Retries allocation of shards that are blocked due to too many subsequent allocation failures
  • timeout – Explicit operation timeout
state(*args, **kwargs)

Get a comprehensive state information of the whole cluster. http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-state.html

Parameters:
  • metric – Limit the information returned to the specified metrics
  • index – A comma-separated list of index names; use _all or empty string to perform the operation on all indices
  • allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
  • flat_settings – Return settings in flat format (default: false)
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • local – Return local information, do not retrieve the state from master node (default: false)
  • master_timeout – Specify timeout for connection to master
stats(*args, **kwargs)

The Cluster Stats API allows to retrieve statistics from a cluster wide perspective. The API returns basic index metrics and information about the current nodes that form the cluster. http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-stats.html

Parameters:
  • node_id – A comma-separated list of node IDs or names to limit the returned information; use _local to return information from the node you’re connecting to, leave empty to get information from all nodes
  • flat_settings – Return settings in flat format (default: false)
  • timeout – Explicit operation timeout

Nodes

class elasticsearch.client.NodesClient(client)
hot_threads(*args, **kwargs)

An API allowing to get the current hot threads on each node in the cluster. https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-hot-threads.html

Parameters:
  • node_id – A comma-separated list of node IDs or names to limit the returned information; use _local to return information from the node you’re connecting to, leave empty to get information from all nodes
  • type – The type to sample (default: cpu), valid choices are: ‘cpu’, ‘wait’, ‘block’
  • ignore_idle_threads – Don’t show threads that are in known-idle places, such as waiting on a socket select or pulling from an empty task queue (default: true)
  • interval – The interval for the second sampling of threads
  • snapshots – Number of samples of thread stacktrace (default: 10)
  • threads – Specify the number of threads to provide information for (default: 3)
  • timeout – Explicit operation timeout
info(*args, **kwargs)

The cluster nodes info API allows to retrieve one or more (or all) of the cluster nodes information. https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-info.html

Parameters:
  • node_id – A comma-separated list of node IDs or names to limit the returned information; use _local to return information from the node you’re connecting to, leave empty to get information from all nodes
  • metric – A comma-separated list of metrics you wish returned. Leave empty to return all.
  • flat_settings – Return settings in flat format (default: false)
  • timeout – Explicit operation timeout
stats(*args, **kwargs)

The cluster nodes stats API allows to retrieve one or more (or all) of the cluster nodes statistics. https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-stats.html

Parameters:
  • node_id – A comma-separated list of node IDs or names to limit the returned information; use _local to return information from the node you’re connecting to, leave empty to get information from all nodes
  • metric – Limit the information returned to the specified metrics
  • index_metric – Limit the information returned for indices metric to the specific index metrics. Isn’t used if indices (or all) metric isn’t specified.
  • completion_fields – A comma-separated list of fields for fielddata and suggest index metric (supports wildcards)
  • fielddata_fields – A comma-separated list of fields for fielddata index metric (supports wildcards)
  • fields – A comma-separated list of fields for fielddata and completion index metric (supports wildcards)
  • groups – A comma-separated list of search groups for search index metric
  • include_segment_file_sizes – Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested), default False
  • level – Return indices stats aggregated at index, node or shard level, default ‘node’, valid choices are: ‘indices’, ‘node’, ‘shards’
  • timeout – Explicit operation timeout
  • types – A comma-separated list of document types for the indexing index metric
usage(*args, **kwargs)

The cluster nodes usage API allows to retrieve information on the usage of features for each node. http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-usage.html

Parameters:
  • node_id – A comma-separated list of node IDs or names to limit the returned information; use _local to return information from the node you’re connecting to, leave empty to get information from all nodes
  • metric – Limit the information returned to the specified metrics
  • human – Whether to return time and byte values in human-readable format., default False
  • timeout – Explicit operation timeout

Cat

class elasticsearch.client.CatClient(client)
aliases(*args, **kwargs)

https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-alias.html

Parameters:
  • name – A comma-separated list of alias names to return
  • format – a short version of the Accept header, e.g. json, yaml
  • h – Comma-separated list of column names to display
  • help – Return help information, default False
  • local – Return local information, do not retrieve the state from master node (default: false)
  • master_timeout – Explicit operation timeout for connection to master node
  • s – Comma-separated list of column names or column aliases to sort by
  • v – Verbose mode. Display column headers, default False
allocation(*args, **kwargs)

Allocation provides a snapshot of how shards have located around the cluster and the state of disk usage. https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-allocation.html

Parameters:
  • node_id – A comma-separated list of node IDs or names to limit the returned information
  • bytes – The unit in which to display byte values, valid choices are: ‘b’, ‘k’, ‘kb’, ‘m’, ‘mb’, ‘g’, ‘gb’, ‘t’, ‘tb’, ‘p’, ‘pb’
  • format – a short version of the Accept header, e.g. json, yaml
  • h – Comma-separated list of column names to display
  • help – Return help information, default False
  • local – Return local information, do not retrieve the state from master node (default: false)
  • master_timeout – Explicit operation timeout for connection to master node
  • s – Comma-separated list of column names or column aliases to sort by
  • v – Verbose mode. Display column headers, default False
count(*args, **kwargs)

Count provides quick access to the document count of the entire cluster, or individual indices. https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-count.html

Parameters:
  • index – A comma-separated list of index names to limit the returned information
  • format – a short version of the Accept header, e.g. json, yaml
  • h – Comma-separated list of column names to display
  • help – Return help information, default False
  • local – Return local information, do not retrieve the state from master node (default: false)
  • master_timeout – Explicit operation timeout for connection to master node
  • s – Comma-separated list of column names or column aliases to sort by
  • v – Verbose mode. Display column headers, default False
fielddata(*args, **kwargs)

Shows information about currently loaded fielddata on a per-node basis. https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-fielddata.html

Parameters:
  • fields – A comma-separated list of fields to return the fielddata size
  • bytes – The unit in which to display byte values, valid choices are: ‘b’, ‘k’, ‘kb’, ‘m’, ‘mb’, ‘g’, ‘gb’, ‘t’, ‘tb’, ‘p’, ‘pb’
  • format – a short version of the Accept header, e.g. json, yaml
  • h – Comma-separated list of column names to display
  • help – Return help information, default False
  • local – Return local information, do not retrieve the state from master node (default: false)
  • master_timeout – Explicit operation timeout for connection to master node
  • s – Comma-separated list of column names or column aliases to sort by
  • v – Verbose mode. Display column headers, default False
health(*args, **kwargs)

health is a terse, one-line representation of the same information from health() API https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-health.html

Parameters:
  • format – a short version of the Accept header, e.g. json, yaml
  • h – Comma-separated list of column names to display
  • help – Return help information, default False
  • local – Return local information, do not retrieve the state from master node (default: false)
  • master_timeout – Explicit operation timeout for connection to master node
  • s – Comma-separated list of column names or column aliases to sort by
  • ts – Set to false to disable timestamping, default True
  • v – Verbose mode. Display column headers, default False
help(*args, **kwargs)

A simple help for the cat api. https://www.elastic.co/guide/en/elasticsearch/reference/current/cat.html

Parameters:
  • help – Return help information, default False
  • s – Comma-separated list of column names or column aliases to sort by
indices(*args, **kwargs)

The indices command provides a cross-section of each index. https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-indices.html

Parameters:
  • index – A comma-separated list of index names to limit the returned information
  • bytes – The unit in which to display byte values, valid choices are: ‘b’, ‘k’, ‘m’, ‘g’
  • format – a short version of the Accept header, e.g. json, yaml
  • h – Comma-separated list of column names to display
  • health – A health status (“green”, “yellow”, or “red” to filter only indices matching the specified health status, default None, valid choices are: ‘green’, ‘yellow’, ‘red’
  • help – Return help information, default False
  • local – Return local information, do not retrieve the state from master node (default: false)
  • master_timeout – Explicit operation timeout for connection to master node
  • pri – Set to true to return stats only for primary shards, default False
  • s – Comma-separated list of column names or column aliases to sort by
  • v – Verbose mode. Display column headers, default False
master(*args, **kwargs)

Displays the master’s node ID, bound IP address, and node name. https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-master.html

Parameters:
  • format – a short version of the Accept header, e.g. json, yaml
  • h – Comma-separated list of column names to display
  • help – Return help information, default False
  • local – Return local information, do not retrieve the state from master node (default: false)
  • master_timeout – Explicit operation timeout for connection to master node
  • s – Comma-separated list of column names or column aliases to sort by
  • v – Verbose mode. Display column headers, default False
nodeattrs(*args, **kwargs)

https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-nodeattrs.html

Parameters:
  • format – a short version of the Accept header, e.g. json, yaml
  • h – Comma-separated list of column names to display
  • help – Return help information, default False
  • local – Return local information, do not retrieve the state from master node (default: false)
  • master_timeout – Explicit operation timeout for connection to master node
  • s – Comma-separated list of column names or column aliases to sort by
  • v – Verbose mode. Display column headers, default False
nodes(*args, **kwargs)

The nodes command shows the cluster topology. https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-nodes.html

Parameters:
  • format – a short version of the Accept header, e.g. json, yaml
  • full_id – Return the full node ID instead of the shortened version (default: false)
  • h – Comma-separated list of column names to display
  • help – Return help information, default False
  • local – Return local information, do not retrieve the state from master node (default: false)
  • master_timeout – Explicit operation timeout for connection to master node
  • s – Comma-separated list of column names or column aliases to sort by
  • v – Verbose mode. Display column headers, default False
pending_tasks(*args, **kwargs)

pending_tasks provides the same information as the pending_tasks() API in a convenient tabular format. https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-pending-tasks.html

Parameters:
  • format – a short version of the Accept header, e.g. json, yaml
  • h – Comma-separated list of column names to display
  • help – Return help information, default False
  • local – Return local information, do not retrieve the state from master node (default: false)
  • master_timeout – Explicit operation timeout for connection to master node
  • s – Comma-separated list of column names or column aliases to sort by
  • v – Verbose mode. Display column headers, default False
plugins(*args, **kwargs)

https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-plugins.html

Parameters:
  • format – a short version of the Accept header, e.g. json, yaml
  • h – Comma-separated list of column names to display
  • help – Return help information, default False
  • local – Return local information, do not retrieve the state from master node (default: false)
  • master_timeout – Explicit operation timeout for connection to master node
  • s – Comma-separated list of column names or column aliases to sort by
  • v – Verbose mode. Display column headers, default False
recovery(*args, **kwargs)

recovery is a view of shard replication. https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-recovery.html

Parameters:
  • index – A comma-separated list of index names to limit the returned information
  • bytes – The unit in which to display byte values, valid choices are: ‘b’, ‘k’, ‘kb’, ‘m’, ‘mb’, ‘g’, ‘gb’, ‘t’, ‘tb’, ‘p’, ‘pb’
  • format – a short version of the Accept header, e.g. json, yaml
  • h – Comma-separated list of column names to display
  • help – Return help information, default False
  • master_timeout – Explicit operation timeout for connection to master node
  • s – Comma-separated list of column names or column aliases to sort by
  • v – Verbose mode. Display column headers, default False
repositories(*args, **kwargs)

https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-repositories.html

Parameters:
  • format – a short version of the Accept header, e.g. json, yaml
  • h – Comma-separated list of column names to display
  • help – Return help information, default False
  • local – Return local information, do not retrieve the state from master node, default False
  • master_timeout – Explicit operation timeout for connection to master node
  • s – Comma-separated list of column names or column aliases to sort by
  • v – Verbose mode. Display column headers, default False
segments(*args, **kwargs)

The segments command is the detailed view of Lucene segments per index. https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-segments.html

Parameters:
  • index – A comma-separated list of index names to limit the returned information
  • format – a short version of the Accept header, e.g. json, yaml
  • h – Comma-separated list of column names to display
  • help – Return help information, default False
  • s – Comma-separated list of column names or column aliases to sort by
  • v – Verbose mode. Display column headers, default False
shards(*args, **kwargs)

The shards command is the detailed view of what nodes contain which shards. https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-shards.html

Parameters:
  • index – A comma-separated list of index names to limit the returned information
  • format – a short version of the Accept header, e.g. json, yaml
  • h – Comma-separated list of column names to display
  • help – Return help information, default False
  • local – Return local information, do not retrieve the state from master node (default: false)
  • master_timeout – Explicit operation timeout for connection to master node
  • s – Comma-separated list of column names or column aliases to sort by
  • v – Verbose mode. Display column headers, default False
snapshots(*args, **kwargs)

https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-snapshots.html

Parameters:
  • repository – Name of repository from which to fetch the snapshot information
  • format – a short version of the Accept header, e.g. json, yaml
  • h – Comma-separated list of column names to display
  • help – Return help information, default False
  • ignore_unavailable – Set to true to ignore unavailable snapshots, default False
  • master_timeout – Explicit operation timeout for connection to master node
  • s – Comma-separated list of column names or column aliases to sort by
  • v – Verbose mode. Display column headers, default False
tasks(*args, **kwargs)

https://www.elastic.co/guide/en/elasticsearch/reference/current/tasks.html

Parameters:
  • actions – A comma-separated list of actions that should be returned. Leave empty to return all.
  • detailed – Return detailed task information (default: false)
  • format – a short version of the Accept header, e.g. json, yaml
  • h – Comma-separated list of column names to display
  • help – Return help information, default False
  • node_id – A comma-separated list of node IDs or names to limit the returned information; use _local to return information from the node you’re connecting to, leave empty to get information from all nodes
  • parent_node – Return tasks with specified parent node.
  • parent_task – Return tasks with specified parent task id. Set to -1 to return all.
  • s – Comma-separated list of column names or column aliases to sort by
  • v – Verbose mode. Display column headers, default False
templates(*args, **kwargs)

https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-templates.html

Parameters:
  • name – A pattern that returned template names must match
  • format – a short version of the Accept header, e.g. json, yaml
  • h – Comma-separated list of column names to display
  • help – Return help information, default False
  • local – Return local information, do not retrieve the state from master node (default: false)
  • master_timeout – Explicit operation timeout for connection to master node
  • s – Comma-separated list of column names or column aliases to sort by
  • v – Verbose mode. Display column headers, default False
thread_pool(*args, **kwargs)

Get information about thread pools. https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-thread-pool.html

Parameters:
  • thread_pool_patterns – A comma-separated list of regular-expressions to filter the thread pools in the output
  • format – a short version of the Accept header, e.g. json, yaml
  • h – Comma-separated list of column names to display
  • help – Return help information, default False
  • local – Return local information, do not retrieve the state from master node (default: false)
  • master_timeout – Explicit operation timeout for connection to master node
  • s – Comma-separated list of column names or column aliases to sort by
  • size – The multiplier in which to display values, valid choices are: ‘’, ‘k’, ‘m’, ‘g’, ‘t’, ‘p’
  • v – Verbose mode. Display column headers, default False

Snapshot

class elasticsearch.client.SnapshotClient(client)
create(*args, **kwargs)

Create a snapshot in repository http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html

Parameters:
  • repository – A repository name
  • snapshot – A snapshot name
  • body – The snapshot definition
  • master_timeout – Explicit operation timeout for connection to master node
  • wait_for_completion – Should this request wait until the operation has completed before returning, default False
create_repository(*args, **kwargs)

Registers a shared file system repository. http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html

Parameters:
  • repository – A repository name
  • body – The repository definition
  • master_timeout – Explicit operation timeout for connection to master node
  • timeout – Explicit operation timeout
  • verify – Whether to verify the repository after creation
delete(*args, **kwargs)

Deletes a snapshot from a repository. http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html

Parameters:
  • repository – A repository name
  • snapshot – A snapshot name
  • master_timeout – Explicit operation timeout for connection to master node
delete_repository(*args, **kwargs)

Removes a shared file system repository. http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html

Parameters:
  • repository – A comma-separated list of repository names
  • master_timeout – Explicit operation timeout for connection to master node
  • timeout – Explicit operation timeout
get(*args, **kwargs)

Retrieve information about a snapshot. http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html

Parameters:
  • repository – A repository name
  • snapshot – A comma-separated list of snapshot names
  • ignore_unavailable – Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown
  • master_timeout – Explicit operation timeout for connection to master node
  • verbose – Whether to show verbose snapshot info or only show the basic info found in the repository index blob
get_repository(*args, **kwargs)

Return information about registered repositories. http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html

Parameters:
  • repository – A comma-separated list of repository names
  • local – Return local information, do not retrieve the state from master node (default: false)
  • master_timeout – Explicit operation timeout for connection to master node
restore(*args, **kwargs)

Restore a snapshot. http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html

Parameters:
  • repository – A repository name
  • snapshot – A snapshot name
  • body – Details of what to restore
  • master_timeout – Explicit operation timeout for connection to master node
  • wait_for_completion – Should this request wait until the operation has completed before returning, default False
status(*args, **kwargs)

Return information about all currently running snapshots. By specifying a repository name, it’s possible to limit the results to a particular repository. http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html

Parameters:
  • repository – A repository name
  • snapshot – A comma-separated list of snapshot names
  • ignore_unavailable – Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown
  • master_timeout – Explicit operation timeout for connection to master node
verify_repository(*args, **kwargs)

Returns a list of nodes where repository was successfully verified or an error message if verification process failed. http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html

Parameters:
  • repository – A repository name
  • master_timeout – Explicit operation timeout for connection to master node
  • timeout – Explicit operation timeout

Tasks

class elasticsearch.client.TasksClient(client)
cancel(*args, **kwargs)

http://www.elastic.co/guide/en/elasticsearch/reference/current/tasks.html

Parameters:
  • task_id – Cancel the task with specified task id (node_id:task_number)
  • actions – A comma-separated list of actions that should be cancelled. Leave empty to cancel all.
  • node_id – A comma-separated list of node IDs or names to limit the returned information; use _local to return information from the node you’re connecting to, leave empty to get information from all nodes
  • parent_node – Cancel tasks with specified parent node.
  • parent_task – Cancel tasks with specified parent task id (node_id:task_number). Set to -1 to cancel all.
get(*args, **kwargs)

Retrieve information for a particular task. http://www.elastic.co/guide/en/elasticsearch/reference/current/tasks.html

Parameters:
  • task_id – Return the task with specified id (node_id:task_number)
  • wait_for_completion – Wait for the matching tasks to complete (default: false)
list(*args, **kwargs)

http://www.elastic.co/guide/en/elasticsearch/reference/current/tasks.html

Parameters:
  • actions – A comma-separated list of actions that should be returned. Leave empty to return all.
  • detailed – Return detailed task information (default: false)
  • group_by – Group tasks by nodes or parent/child relationships, default ‘nodes’, valid choices are: ‘nodes’, ‘parents’
  • node_id – A comma-separated list of node IDs or names to limit the returned information; use _local to return information from the node you’re connecting to, leave empty to get information from all nodes
  • parent_node – Return tasks with specified parent node.
  • parent_task – Return tasks with specified parent task id (node_id:task_number). Set to -1 to return all.
  • wait_for_completion – Wait for the matching tasks to complete (default: false)