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.

Tracking Requests with Opaque ID

You can enrich your requests against Elasticsearch with an identifier string, that allows you to discover this identifier in deprecation logs, to support you with identifying search slow log origin or to help with identifying running tasks.

from elasticsearch import Elasticsearch

client = Elasticsearch()

# You can apply X-Opaque-Id in any API request via 'opaque_id':
resp = client.get(index="test", id="1", opaque_id="request-1")

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
    verify_certs=True,
    # provide a path to CA certs on disk
    ca_certs='/path/to/CA_certs'
)

If using SSL, but don’t verify the certs, a warning message is showed optionally (see Urllib3HttpConnection for detailed description of the options):

es = Elasticsearch(
    ['localhost:443', 'other_host:443'],
    # turn on SSL
    use_ssl=True,
    # no verify SSL certificates
    verify_certs=False,
    # don't show warnings about ssl certs verification
    ssl_show_warn=False
)

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
    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
)

By default, JSONSerializer is used to encode all outgoing requests. However, you can implement your own custom serializer:

from elasticsearch.serializer import JSONSerializer

class SetEncoder(JSONSerializer):
    def default(self, obj):
        if isinstance(obj, set):
            return list(obj)
        if isinstance(obj, Something):
            return 'CustomSomethingRepresentation'
        return JSONSerializer.default(self, obj)

es = Elasticsearch(serializer=SetEncoder())
Parameters:
  • hosts – list of nodes, or a single node, 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 Connection 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(**kwargs)

Allows to perform multiple index/update/delete operations in a single request. https://www.elastic.co/guide/en/elasticsearch/reference/master/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_excludes – Default list of fields to exclude from the returned _source field, can be overridden on each sub-request
  • _source_includes – Default list of fields to extract and return from the _source field, can be overridden on each sub-request
  • 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: 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(**kwargs)

Explicitly clears the search context for a scroll. https://www.elastic.co/guide/en/elasticsearch/reference/master/search-request-body.html#_clear_scroll_api

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

Returns number of documents matching a query. https://www.elastic.co/guide/en/elasticsearch/reference/master/search-count.html

Parameters:
  • body – A query to restrict the results specified with the Query DSL (optional)
  • index – A comma-separated list of indices to restrict the results
  • doc_type – A comma-separated list of types to restrict the results
  • 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) Valid choices: AND, OR Default: 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. Valid choices: open, closed, hidden, none, all Default: open
  • ignore_throttled – Whether specified concrete, expanded or aliased indices should be ignored when throttled
  • 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 – A comma-separated list of specific routing values
  • terminate_after – The maximum count for each shard, upon reaching which the query execution will terminate early
create(**kwargs)

Creates a new document in the index. Returns a 409 response when a document with a same ID already exists in the index. https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html

Parameters:
  • index – The name of the index
  • id – Document ID
  • body – The document
  • doc_type – The type of the 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: 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: internal, external, external_gte
  • 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(**kwargs)

Removes a document from the index. https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete.html

Parameters:
  • index – The name of the index
  • id – The document ID
  • doc_type – The type of the document
  • if_primary_term – only perform the delete operation if the last operation that has changed the document has the specified primary term
  • if_seq_no – only perform the delete operation if the last operation that has changed the document has the specified sequence number
  • 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: 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: 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(**kwargs)

Deletes documents matching the provided query. https://www.elastic.co/guide/en/elasticsearch/reference/master/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_excludes – A list of fields to exclude from the returned _source field
  • _source_includes – 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? Valid choices: abort, proceed Default: abort
  • default_operator – The default operator for query string query (AND or OR) Valid choices: AND, OR Default: 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. Valid choices: open, closed, hidden, none, all Default: open
  • 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_docs – Maximum number of documents to process (default: all documents)
  • 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.
  • 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 delete by query Default: 100
  • search_timeout – Explicit timeout for each search request. Defaults to no timeout.
  • search_type – Search operation type Valid choices: query_then_fetch, dfs_query_then_fetch
  • size – Deprecated, please use max_docs instead
  • slices – The number of slices this task should be divided into. Defaults to 1, meaning the task isn’t sliced into subtasks. Can be set to auto. 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_by_query_rethrottle(**kwargs)

Changes the number of requests per second for a particular Delete By Query operation. https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.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.
delete_script(**kwargs)

Deletes a script. https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html

Parameters:
  • id – Script ID
  • master_timeout – Specify timeout for connection to master
  • timeout – Explicit operation timeout
exists(**kwargs)

Returns information about whether a document exists in an index. https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html

Parameters:
  • index – The name of the index
  • id – The document ID
  • doc_type – The type of the document (use _all to fetch the first document matching the ID across all types)
  • _source – True or false to return the _source field or not, or a list of fields to return
  • _source_excludes – A list of fields to exclude from the returned _source field
  • _source_includes – 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
  • version – Explicit version number for concurrency control
  • version_type – Specific version type Valid choices: internal, external, external_gte, force
exists_source(**kwargs)

Returns information about whether a document source exists in an index. https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html

Parameters:
  • index – The name of the index
  • id – The document ID
  • doc_type – The type of the document; deprecated and optional starting with 7.0
  • _source – True or false to return the _source field or not, or a list of fields to return
  • _source_excludes – A list of fields to exclude from the returned _source field
  • _source_includes – 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
  • version – Explicit version number for concurrency control
  • version_type – Specific version type Valid choices: internal, external, external_gte, force
explain(**kwargs)

Returns information about why a specific matches (or doesn’t match) a query. https://www.elastic.co/guide/en/elasticsearch/reference/master/search-explain.html

Parameters:
  • index – The name of the index
  • id – The document ID
  • body – The query definition using the Query DSL
  • 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_excludes – A list of fields to exclude from the returned _source field
  • _source_includes – 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) Valid choices: AND, OR Default: 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
  • 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(**kwargs)

Returns the information about the capabilities of fields among multiple indices. https://www.elastic.co/guide/en/elasticsearch/reference/master/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
  • 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. Valid choices: open, closed, hidden, none, all Default: open
  • fields – A comma-separated list of field names
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • include_unmapped – Indicates whether unmapped fields should be included in the response.
get(**kwargs)

Returns a document. https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html

Parameters:
  • index – The name of the index
  • id – The document ID
  • doc_type – The type of the document (use _all to fetch the first document matching the ID across all types)
  • _source – True or false to return the _source field or not, or a list of fields to return
  • _source_excludes – A list of fields to exclude from the returned _source field
  • _source_includes – 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
  • version – Explicit version number for concurrency control
  • version_type – Specific version type Valid choices: internal, external, external_gte, force
get_script(**kwargs)

Returns a script. https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html

Parameters:
  • id – Script ID
  • master_timeout – Specify timeout for connection to master
get_script_context(**kwargs)

Returns all script contexts. https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-contexts.html

get_script_languages(**kwargs)

Returns available script types, languages and contexts https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html

get_source(**kwargs)

Returns the source of a document. https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html

Parameters:
  • index – The name of the index
  • id – The document ID
  • doc_type – The type of the document; deprecated and optional starting with 7.0
  • _source – True or false to return the _source field or not, or a list of fields to return
  • _source_excludes – A list of fields to exclude from the returned _source field
  • _source_includes – 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
  • version – Explicit version number for concurrency control
  • version_type – Specific version type Valid choices: internal, external, external_gte, force
index(**kwargs)

Creates or updates a document in an index. https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html

Parameters:
  • index – The name of the index
  • body – The document
  • doc_type – The type of the document
  • id – Document ID
  • if_primary_term – only perform the index operation if the last operation that has changed the document has the specified primary term
  • if_seq_no – only perform the index operation if the last operation that has changed the document has the specified sequence number
  • op_type – Explicit operation type. Defaults to index for requests with an explicit document ID, and to `create`for requests without an explicit document ID Valid choices: index, create
  • 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: 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: internal, external, external_gte
  • 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(**kwargs)

Returns basic information about the cluster. https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html

mget(**kwargs)

Allows to get multiple documents in one request. https://www.elastic.co/guide/en/elasticsearch/reference/master/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_excludes – A list of fields to exclude from the returned _source field
  • _source_includes – 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(**kwargs)

Allows to execute several search operations in one request. https://www.elastic.co/guide/en/elasticsearch/reference/master/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
  • ccs_minimize_roundtrips – Indicates whether network round- trips should be minimized as part of cross-cluster search requests execution Default: true
  • max_concurrent_searches – Controls the maximum number of concurrent searches the multi search api will execute
  • max_concurrent_shard_requests – The number of concurrent shard requests each sub search executes concurrently per node. 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: 5
  • 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 its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint.
  • rest_total_hits_as_int – Indicates whether hits.total should be rendered as an integer or an object in the rest search response
  • search_type – Search operation type Valid choices: 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(**kwargs)

Allows to execute several search template operations in one request. https://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
  • ccs_minimize_roundtrips – Indicates whether network round- trips should be minimized as part of cross-cluster search requests execution Default: true
  • max_concurrent_searches – Controls the maximum number of concurrent searches the multi search api will execute
  • rest_total_hits_as_int – Indicates whether hits.total should be rendered as an integer or an object in the rest search response
  • search_type – Search operation type Valid choices: 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(**kwargs)

Returns multiple termvectors in one request. https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-multi-termvectors.html

Parameters:
  • 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.
  • index – The index in which the document resides.
  • doc_type – The type of the document.
  • 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
  • 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”.
  • version – Explicit version number for concurrency control
  • version_type – Specific version type Valid choices: internal, external, external_gte, force
ping(**kwargs)

Returns whether the cluster is running. https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html

put_script(**kwargs)

Creates or updates a script. https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html

Parameters:
  • id – Script ID
  • body – The document
  • context – Context name to compile script against
  • master_timeout – Specify timeout for connection to master
  • timeout – Explicit operation timeout
rank_eval(**kwargs)

Allows to evaluate the quality of ranked search results over a set of typical search queries https://www.elastic.co/guide/en/elasticsearch/reference/master/search-rank-eval.html

Parameters:
  • body – The ranking evaluation search definition, including search requests, document ratings and ranking metric definition.
  • 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. Valid choices: open, closed, hidden, none, all Default: open
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • search_type – Search operation type Valid choices: query_then_fetch, dfs_query_then_fetch
reindex(**kwargs)

Allows to copy documents from one index to another, optionally filtering the source documents by a query, changing the destination index settings, or fetching the documents from a remote cluster. https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-reindex.html

Parameters:
  • body – The search definition using the Query DSL and the prototype for the index request.
  • max_docs – Maximum number of documents to process (default: all documents)
  • refresh – Should the affected indexes be refreshed?
  • requests_per_second – The throttle to set on this request in sub-requests per second. -1 means no throttle.
  • scroll – Control how long to keep the search context alive Default: 5m
  • slices – The number of slices this task should be divided into. Defaults to 1, meaning the task isn’t sliced into subtasks. Can be set to auto. 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(**kwargs)

Changes the number of requests per second for a particular Reindex operation. https://www.elastic.co/guide/en/elasticsearch/reference/master/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(**kwargs)

Allows to use the Mustache language to pre-render a search definition. https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html#_validating_templates

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

Allows an arbitrary script to be executed and a result to be returned https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-execute-api.html

Parameters:body – The script to execute
scroll(**kwargs)

Allows to retrieve a large numbers of results from a single search request. https://www.elastic.co/guide/en/elasticsearch/reference/master/search-request-body.html#request-body-search-scroll

Parameters:
  • body – The scroll ID if not passed by URL or query parameter.
  • scroll_id – The scroll ID for scrolled search
  • rest_total_hits_as_int – Indicates whether hits.total should be rendered as an integer or an object in the rest search response
  • scroll – Specify how long a consistent view of the index should be maintained for scrolled search
search(**kwargs)

Returns results matching a query. https://www.elastic.co/guide/en/elasticsearch/reference/master/search-search.html

Parameters:
  • body – The search definition using the Query DSL
  • 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
  • _source – True or false to return the _source field or not, or a list of fields to return
  • _source_excludes – A list of fields to exclude from the returned _source field
  • _source_includes – 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)
  • allow_partial_search_results – Indicate if an error should be returned if there is a partial search failure or timeout Default: True
  • 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
  • ccs_minimize_roundtrips – Indicates whether network round- trips should be minimized as part of cross-cluster search requests execution Default: true
  • default_operator – The default operator for query string query (AND or OR) Valid choices: AND, OR Default: 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. Valid choices: open, closed, hidden, none, all Default: open
  • explain – Specify whether to return detailed information about score computation as part of a hit
  • from – Starting offset (default: 0)
  • ignore_throttled – Whether specified concrete, expanded or aliased indices should be ignored when throttled
  • 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 per node 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: 5
  • 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 its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint.
  • 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
  • rest_total_hits_as_int – Indicates whether hits.total should be rendered as an integer or an object in the rest search response
  • 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: query_then_fetch, dfs_query_then_fetch
  • seq_no_primary_term – Specify whether to return sequence number and primary term of the last modification of each hit
  • 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 Valid choices: missing, popular, always Default: missing
  • 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(**kwargs)

Returns information about the indices and shards that a search request would be executed against. https://www.elastic.co/guide/en/elasticsearch/reference/master/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. Valid choices: open, closed, hidden, none, all Default: open
  • 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(**kwargs)

Allows to use the Mustache language to pre-render a search definition. https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html

Parameters:
  • body – The search definition template and its params
  • 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
  • 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)
  • ccs_minimize_roundtrips – Indicates whether network round- trips should be minimized as part of cross-cluster search requests execution Default: true
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both. Valid choices: open, closed, hidden, none, all Default: open
  • explain – Specify whether to return detailed information about score computation as part of a hit
  • ignore_throttled – Whether specified concrete, expanded or aliased indices should be ignored when throttled
  • 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
  • rest_total_hits_as_int – Indicates whether hits.total should be rendered as an integer or an object in the rest search response
  • 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: 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(**kwargs)

Returns information and statistics about terms in the fields of a particular document. https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-termvectors.html

Parameters:
  • index – The index in which the document resides.
  • body – Define parameters and or supply a document to get termvectors for. See documentation.
  • doc_type – The type of the document.
  • id – The id of the document, when not specified a doc param should be supplied.
  • 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
  • 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.
  • version – Explicit version number for concurrency control
  • version_type – Specific version type Valid choices: internal, external, external_gte, force
update(**kwargs)

Updates a document with a script or partial document. https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update.html

Parameters:
  • index – The name of the index
  • id – Document ID
  • body – The request definition requires either script or partial doc
  • 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_excludes – A list of fields to exclude from the returned _source field
  • _source_includes – A list of fields to extract and return from the _source field
  • if_primary_term – only perform the update operation if the last operation that has changed the document has the specified primary term
  • if_seq_no – only perform the update operation if the last operation that has changed the document has the specified sequence number
  • lang – The script language (default: painless)
  • 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: 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
  • 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(**kwargs)

Performs an update on every document in the index without changing the source, for example to pick up a mapping change. https://www.elastic.co/guide/en/elasticsearch/reference/master/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
  • 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_excludes – A list of fields to exclude from the returned _source field
  • _source_includes – 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? Valid choices: abort, proceed Default: abort
  • default_operator – The default operator for query string query (AND or OR) Valid choices: AND, OR Default: 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. Valid choices: open, closed, hidden, none, all Default: open
  • 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_docs – Maximum number of documents to process (default: all documents)
  • 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 affected 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.
  • 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 Default: 100
  • search_timeout – Explicit timeout for each search request. Defaults to no timeout.
  • search_type – Search operation type Valid choices: query_then_fetch, dfs_query_then_fetch
  • size – Deprecated, please use max_docs instead
  • slices – The number of slices this task should be divided into. Defaults to 1, meaning the task isn’t sliced into subtasks. Can be set to auto. 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
update_by_query_rethrottle(**kwargs)

Changes the number of requests per second for a particular Update By Query operation. https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.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.

Indices

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

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

Parameters:
  • body – Define analyzer/tokenizer parameters and the text on which the analysis should be performed
  • index – The name of the index to scope the operation
clear_cache(**kwargs)

Clears all or specific caches for one or more indices. https://www.elastic.co/guide/en/elasticsearch/reference/master/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. Valid choices: open, closed, hidden, none, all Default: open
  • fielddata – Clear field data
  • fields – A comma-separated list of fields to clear when using the fielddata parameter (default: all)
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • query – Clear query caches
  • request – Clear request cache
clone(**kwargs)

Clones an index https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-clone-index.html

Parameters:
  • index – The name of the source index to clone
  • target – The name of the target index to clone 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 cloned index before the operation returns.
close(**kwargs)

Closes an index. https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-open-close.html

Parameters:
  • index – A comma separated list of indices to close
  • 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. Valid choices: open, closed, hidden, none, all Default: open
  • 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
  • wait_for_active_shards – Sets the number of active shards to wait for before the operation returns.
create(**kwargs)

Creates an index with optional settings and mappings. https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-create-index.html

Parameters:
  • index – The name of the index
  • body – The configuration for the index (settings and mappings)
  • include_type_name – Whether a type should be expected in the body of the mappings.
  • 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 before the operation returns.
create_data_stream(**kwargs)

Creates or updates a data stream https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html

Parameters:
  • name – The name of the data stream
  • body – The data stream definition
delete(**kwargs)

Deletes an index. https://www.elastic.co/guide/en/elasticsearch/reference/master/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) Valid choices: open, closed, hidden, none, all Default: open
  • ignore_unavailable – Ignore unavailable indexes (default: false)
  • master_timeout – Specify timeout for connection to master
  • timeout – Explicit operation timeout
delete_alias(**kwargs)

Deletes an alias. https://www.elastic.co/guide/en/elasticsearch/reference/master/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 timestamp for the document
delete_data_stream(**kwargs)

Deletes a data stream. https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html

Parameters:name – The name of the data stream
delete_template(**kwargs)

Deletes an index template. https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html

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

Returns information about whether a particular index exists. https://www.elastic.co/guide/en/elasticsearch/reference/master/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) Valid choices: open, closed, hidden, none, all Default: open
  • 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.
  • local – Return local information, do not retrieve the state from master node (default: false)
exists_alias(**kwargs)

Returns information about whether a particular alias exists. https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html

Parameters:
  • name – A comma-separated list of alias names to return
  • index – A comma-separated list of index names to filter aliases
  • 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. Valid choices: open, closed, hidden, none, all Default: 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(**kwargs)

Returns information about whether a particular index template exists. https://www.elastic.co/guide/en/elasticsearch/reference/master/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(**kwargs)

Returns information about whether a particular document type exists. (DEPRECATED) https://www.elastic.co/guide/en/elasticsearch/reference/master/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. Valid choices: open, closed, hidden, none, all Default: open
  • 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(**kwargs)

Performs the flush operation on one or more indices. https://www.elastic.co/guide/en/elasticsearch/reference/master/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. Valid choices: open, closed, hidden, none, all Default: open
  • 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(**kwargs)

Performs a synced flush operation on one or more indices. Synced flush is deprecated and will be removed in 8.0. Use flush instead https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-synced-flush-api.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. Valid choices: open, closed, none, all Default: open
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
forcemerge(**kwargs)

Performs the force merge operation on one or more indices. https://www.elastic.co/guide/en/elasticsearch/reference/master/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. Valid choices: open, closed, hidden, none, all Default: open
  • 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
freeze(**kwargs)

Freezes an index. A frozen index has almost no overhead on the cluster (except for maintaining its metadata in memory) and is read-only. https://www.elastic.co/guide/en/elasticsearch/reference/current/freeze-index-api.html

Parameters:
  • index – The name of the index to freeze
  • 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. Valid choices: open, closed, hidden, none, all Default: closed
  • 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
  • wait_for_active_shards – Sets the number of active shards to wait for before the operation returns.
get(**kwargs)

Returns information about one or more indices. https://www.elastic.co/guide/en/elasticsearch/reference/master/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) Valid choices: open, closed, hidden, none, all Default: open
  • 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.
  • include_type_name – Whether to add the type name to the response (default: false)
  • local – Return local information, do not retrieve the state from master node (default: false)
  • master_timeout – Specify timeout for connection to master
get_alias(**kwargs)

Returns an alias. https://www.elastic.co/guide/en/elasticsearch/reference/master/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. Valid choices: open, closed, hidden, none, all Default: 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_data_streams(**kwargs)

Returns data streams. https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html

Parameters:name – The comma separated names of data streams
get_field_mapping(**kwargs)

Returns mapping for one or more fields. https://www.elastic.co/guide/en/elasticsearch/reference/master/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. Valid choices: open, closed, hidden, none, all Default: open
  • 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
  • include_type_name – Whether a type should be returned in the body of the mappings.
  • local – Return local information, do not retrieve the state from master node (default: false)
get_mapping(**kwargs)

Returns mappings for one or more indices. https://www.elastic.co/guide/en/elasticsearch/reference/master/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. Valid choices: open, closed, hidden, none, all Default: open
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • include_type_name – Whether to add the type name to the response (default: false)
  • local – Return local information, do not retrieve the state from master node (default: false)
  • master_timeout – Specify timeout for connection to master
get_settings(**kwargs)

Returns settings for one or more indices. https://www.elastic.co/guide/en/elasticsearch/reference/master/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. Valid choices: open, closed, hidden, none, all Default: 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.
  • local – Return local information, do not retrieve the state from master node (default: false)
  • master_timeout – Specify timeout for connection to master
get_template(**kwargs)

Returns an index template. https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html

Parameters:
  • name – The comma separated names of the index templates
  • flat_settings – Return settings in flat format (default: false)
  • include_type_name – Whether a type should be returned in the body of the mappings.
  • 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(**kwargs)

The _upgrade API is no longer useful and will be removed. https://www.elastic.co/guide/en/elasticsearch/reference/master/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. Valid choices: open, closed, hidden, none, all Default: open
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
open(**kwargs)

Opens an index. https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-open-close.html

Parameters:
  • index – A comma separated list of indices to open
  • 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. Valid choices: open, closed, hidden, none, all Default: closed
  • 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
  • wait_for_active_shards – Sets the number of active shards to wait for before the operation returns.
put_alias(**kwargs)

Creates or updates an alias. https://www.elastic.co/guide/en/elasticsearch/reference/master/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 timestamp for the document
put_mapping(**kwargs)

Updates the index mappings. https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-put-mapping.html

Parameters:
  • 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.
  • doc_type – The name of the document type
  • 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. Valid choices: open, closed, hidden, none, all Default: open
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • include_type_name – Whether a type should be expected in the body of the mappings.
  • master_timeout – Specify timeout for connection to master
  • timeout – Explicit operation timeout
put_settings(**kwargs)

Updates the index settings. https://www.elastic.co/guide/en/elasticsearch/reference/master/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. Valid choices: open, closed, hidden, none, all Default: open
  • 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
  • timeout – Explicit operation timeout
put_template(**kwargs)

Creates or updates an index template. https://www.elastic.co/guide/en/elasticsearch/reference/master/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
  • include_type_name – Whether a type should be returned in the body of the mappings.
  • 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)
recovery(**kwargs)

Returns information about ongoing index shard recoveries. https://www.elastic.co/guide/en/elasticsearch/reference/master/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
  • detailed – Whether to display detailed information about shard recovery
refresh(**kwargs)

Performs the refresh operation in one or more indices. https://www.elastic.co/guide/en/elasticsearch/reference/master/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. Valid choices: open, closed, hidden, none, all Default: open
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
reload_search_analyzers(**kwargs)

Reloads an index’s search analyzers and their resources. https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-reload-analyzers.html

Parameters:
  • index – A comma-separated list of index names to reload analyzers for
  • 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. Valid choices: open, closed, hidden, none, all Default: open
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
rollover(**kwargs)

Updates an alias to point to a new index when the existing index is considered to be too large or too old. https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-rollover-index.html

Parameters:
  • alias – The name of the alias to rollover
  • body – The conditions that needs to be met for executing rollover
  • new_index – The name of the rollover index
  • 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
  • include_type_name – Whether a type should be included in the body of the mappings.
  • 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(**kwargs)

Provides low-level information about segments in a Lucene index. https://www.elastic.co/guide/en/elasticsearch/reference/master/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. Valid choices: open, closed, hidden, none, all Default: open
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • verbose – Includes detailed memory usage by Lucene.
shard_stores(**kwargs)

Provides store information for shard copies of indices. https://www.elastic.co/guide/en/elasticsearch/reference/master/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. Valid choices: open, closed, hidden, none, all Default: open
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • status – A comma-separated list of statuses used to filter on shards to get store information for Valid choices: green, yellow, red, all
shrink(**kwargs)

Allow to shrink an existing index into a new index with fewer primary shards. https://www.elastic.co/guide/en/elasticsearch/reference/master/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)
  • copy_settings – whether or not to copy settings from the source index (defaults to 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 shrunken index before the operation returns.
split(**kwargs)

Allows you to split an existing index into a new index with more primary shards. https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-split-index.html

Parameters:
  • index – The name of the source index to split
  • target – The name of the target index to split into
  • body – The configuration for the target index (settings and aliases)
  • copy_settings – whether or not to copy settings from the source index (defaults to 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 shrunken index before the operation returns.
stats(**kwargs)

Provides statistics on operations happening in an index. https://www.elastic.co/guide/en/elasticsearch/reference/master/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. Valid choices: _all, completion, docs, fielddata, query_cache, flush, get, indexing, merge, request_cache, refresh, search, segments, store, warmer, suggest
  • completion_fields – A comma-separated list of fields for fielddata and suggest index metric (supports wildcards)
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both. Valid choices: open, closed, hidden, none, all Default: open
  • 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)
  • forbid_closed_indices – If set to false stats will also collected from closed indices if explicitly specified or if expand_wildcards expands to closed indices Default: True
  • 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)
  • include_unloaded_segments – If set to true segment stats will include stats for segments that are not currently loaded into memory
  • level – Return stats aggregated at cluster, index or shard level Valid choices: cluster, indices, shards Default: indices
  • types – A comma-separated list of document types for the indexing index metric
unfreeze(**kwargs)

Unfreezes an index. When a frozen index is unfrozen, the index goes through the normal recovery process and becomes writeable again. https://www.elastic.co/guide/en/elasticsearch/reference/current/unfreeze-index-api.html

Parameters:
  • index – The name of the index to unfreeze
  • 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. Valid choices: open, closed, hidden, none, all Default: closed
  • 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
  • wait_for_active_shards – Sets the number of active shards to wait for before the operation returns.
update_aliases(**kwargs)

Updates index aliases. https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html

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

The _upgrade API is no longer useful and will be removed. https://www.elastic.co/guide/en/elasticsearch/reference/master/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. Valid choices: open, closed, hidden, none, all Default: open
  • 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(**kwargs)

Allows a user to validate a potentially expensive query without executing it. https://www.elastic.co/guide/en/elasticsearch/reference/master/search-validate.html

Parameters:
  • body – The query definition specified with the Query DSL
  • 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
  • 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) Valid choices: AND, OR Default: 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. Valid choices: open, closed, hidden, none, all Default: open
  • 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
  • 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(**kwargs)

Deletes a pipeline. https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-pipeline-api.html

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

Returns a pipeline. https://www.elastic.co/guide/en/elasticsearch/reference/master/get-pipeline-api.html

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

Returns a list of the built-in patterns. https://www.elastic.co/guide/en/elasticsearch/reference/master/grok-processor.html#grok-processor-rest-get

put_pipeline(**kwargs)

Creates or updates a pipeline. https://www.elastic.co/guide/en/elasticsearch/reference/master/put-pipeline-api.html

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

Allows to simulate a pipeline with example documents. https://www.elastic.co/guide/en/elasticsearch/reference/master/simulate-pipeline-api.html

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

Cluster

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

Provides explanations for shard allocations in the cluster. https://www.elastic.co/guide/en/elasticsearch/reference/master/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)
delete_component_template(**kwargs)

Deletes a component template https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-templates.html

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

Returns one or more component templates https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-templates.html

Parameters:
  • name – The comma separated names of the component templates
  • 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_settings(**kwargs)

Returns cluster settings. https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-update-settings.html

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

Returns basic information about the health of the cluster. https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-health.html

Parameters:
  • index – Limit the information returned to a specific index
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both. Valid choices: open, closed, hidden, none, all Default: all
  • level – Specify the level of detail for returned information Valid choices: cluster, indices, shards Default: cluster
  • 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: immediate, urgent, high, normal, low, languid
  • wait_for_no_initializing_shards – Whether to wait until there are no initializing shards in the cluster
  • 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 Valid choices: green, yellow, red
pending_tasks(**kwargs)

Returns a list of any cluster-level changes (e.g. create index, update mapping, allocate or fail shard) which have not yet been executed. https://www.elastic.co/guide/en/elasticsearch/reference/master/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_component_template(**kwargs)

Creates or updates a component template https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-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
  • master_timeout – Specify timeout for connection to master
  • timeout – Explicit operation timeout
put_settings(**kwargs)

Updates the cluster settings. https://www.elastic.co/guide/en/elasticsearch/reference/master/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
remote_info(**kwargs)

Returns the information about configured remote clusters. https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-remote-info.html

reroute(**kwargs)

Allows to manually change the allocation of individual shards in the cluster. https://www.elastic.co/guide/en/elasticsearch/reference/master/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: _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(**kwargs)

Returns a comprehensive information about the state of the cluster. https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-state.html

Parameters:
  • metric – Limit the information returned to the specified metrics Valid choices: _all, blocks, metadata, nodes, routing_table, routing_nodes, master_node, version
  • 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. Valid choices: open, closed, hidden, none, all Default: open
  • 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
  • wait_for_metadata_version – Wait for the metadata version to be equal or greater than the specified metadata version
  • wait_for_timeout – The maximum time to wait for wait_for_metadata_version before timing out
stats(**kwargs)

Returns high-level overview of cluster statistics. https://www.elastic.co/guide/en/elasticsearch/reference/master/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(**kwargs)

Returns information about hot threads on each node in the cluster. https://www.elastic.co/guide/en/elasticsearch/reference/master/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
  • doc_type – The type to sample (default: cpu) Valid choices: 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(**kwargs)

Returns information about nodes in the cluster. https://www.elastic.co/guide/en/elasticsearch/reference/master/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. Valid choices: settings, os, process, jvm, thread_pool, transport, http, plugins, ingest
  • flat_settings – Return settings in flat format (default: false)
  • timeout – Explicit operation timeout
reload_secure_settings(**kwargs)

Reloads secure settings. https://www.elastic.co/guide/en/elasticsearch/reference/master/secure-settings.html#reloadable-secure-settings

Parameters:
  • body – An object containing the password for the elasticsearch keystore
  • node_id – A comma-separated list of node IDs to span the reload/reinit call. Should stay empty because reloading usually involves all cluster nodes.
  • timeout – Explicit operation timeout
stats(**kwargs)

Returns statistical information about nodes in the cluster. https://www.elastic.co/guide/en/elasticsearch/reference/master/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 Valid choices: _all, breaker, fs, http, indices, jvm, os, process, thread_pool, transport, discovery
  • 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. Valid choices: _all, completion, docs, fielddata, query_cache, flush, get, indexing, merge, request_cache, refresh, search, segments, store, warmer, suggest
  • 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)
  • level – Return indices stats aggregated at index, node or shard level Valid choices: indices, node, shards Default: node
  • timeout – Explicit operation timeout
  • types – A comma-separated list of document types for the indexing index metric
usage(**kwargs)

Returns low-level information about REST actions usage on nodes. https://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 Valid choices: _all, rest_actions
  • timeout – Explicit operation timeout

Cat

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

Shows information about currently configured aliases to indices including filter and routing infos. https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-alias.html

Parameters:
  • name – A comma-separated list of alias names to return
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both. Valid choices: open, closed, hidden, none, all Default: all
  • 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
  • local – Return local information, do not retrieve the state from master node (default: false)
  • s – Comma-separated list of column names or column aliases to sort by
  • v – Verbose mode. Display column headers
allocation(**kwargs)

Provides a snapshot of how many shards are allocated to each data node and how much disk space they are using. https://www.elastic.co/guide/en/elasticsearch/reference/master/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: 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
  • 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
count(**kwargs)

Provides quick access to the document count of the entire cluster, or individual indices. https://www.elastic.co/guide/en/elasticsearch/reference/master/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
  • s – Comma-separated list of column names or column aliases to sort by
  • v – Verbose mode. Display column headers
fielddata(**kwargs)

Shows how much heap memory is currently being used by fielddata on every data node in the cluster. https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-fielddata.html

Parameters:
  • fields – A comma-separated list of fields to return in the output
  • bytes – The unit in which to display byte values Valid choices: 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
  • s – Comma-separated list of column names or column aliases to sort by
  • v – Verbose mode. Display column headers
health(**kwargs)

Returns a concise representation of the cluster health. https://www.elastic.co/guide/en/elasticsearch/reference/master/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
  • s – Comma-separated list of column names or column aliases to sort by
  • time – The unit in which to display time values Valid choices: d, h, m, s, ms, micros, nanos
  • ts – Set to false to disable timestamping Default: True
  • v – Verbose mode. Display column headers
help(**kwargs)

Returns help for the Cat APIs. https://www.elastic.co/guide/en/elasticsearch/reference/master/cat.html

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

Returns information about indices: number of primaries and replicas, document counts, disk size, … https://www.elastic.co/guide/en/elasticsearch/reference/master/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: b, k, kb, m, mb, g, gb, t, tb, p, pb
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both. Valid choices: open, closed, hidden, none, all Default: all
  • 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 Valid choices: green, yellow, red
  • help – Return help information
  • include_unloaded_segments – If set to true segment stats will include stats for segments that are not currently loaded into memory
  • 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
  • s – Comma-separated list of column names or column aliases to sort by
  • time – The unit in which to display time values Valid choices: d, h, m, s, ms, micros, nanos
  • v – Verbose mode. Display column headers
master(**kwargs)

Returns information about the master node. https://www.elastic.co/guide/en/elasticsearch/reference/master/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
  • 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
ml_data_frame_analytics(**kwargs)

Gets configuration and usage information about data frame analytics jobs. https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-dfanalytics.html

Parameters:
  • id – The ID of the data frame analytics to fetch
  • allow_no_match – Whether to ignore if a wildcard expression matches no configs. (This includes _all string or when no configs have been specified)
  • bytes – The unit in which to display byte values Valid choices: 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
  • s – Comma-separated list of column names or column aliases to sort by
  • time – The unit in which to display time values Valid choices: d, h, m, s, ms, micros, nanos
  • v – Verbose mode. Display column headers
ml_datafeeds(**kwargs)

Gets configuration and usage information about datafeeds. https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-datafeeds.html

Parameters:
  • datafeed_id – The ID of the datafeeds stats to fetch
  • allow_no_datafeeds – Whether to ignore if a wildcard expression matches no datafeeds. (This includes _all string or when no datafeeds have been specified)
  • 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
  • s – Comma-separated list of column names or column aliases to sort by
  • time – The unit in which to display time values Valid choices: d, h, m, s, ms, micros, nanos
  • v – Verbose mode. Display column headers
ml_jobs(**kwargs)

Gets configuration and usage information about anomaly detection jobs. https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-anomaly-detectors.html

Parameters:
  • job_id – The ID of the jobs stats to fetch
  • allow_no_jobs – Whether to ignore if a wildcard expression matches no jobs. (This includes _all string or when no jobs have been specified)
  • bytes – The unit in which to display byte values Valid choices: 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
  • s – Comma-separated list of column names or column aliases to sort by
  • time – The unit in which to display time values Valid choices: d, h, m, s, ms, micros, nanos
  • v – Verbose mode. Display column headers
ml_trained_models(**kwargs)

Gets configuration and usage information about inference trained models. https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-trained-model.html

Parameters:
  • model_id – The ID of the trained models stats to fetch
  • allow_no_match – Whether to ignore if a wildcard expression matches no trained models. (This includes _all string or when no trained models have been specified) Default: True
  • bytes – The unit in which to display byte values Valid choices: b, k, kb, m, mb, g, gb, t, tb, p, pb
  • format – a short version of the Accept header, e.g. json, yaml
  • from – skips a number of trained models
  • h – Comma-separated list of column names to display
  • help – Return help information
  • s – Comma-separated list of column names or column aliases to sort by
  • size – specifies a max number of trained models to get Default: 100
  • time – The unit in which to display time values Valid choices: d, h, m, s, ms, micros, nanos
  • v – Verbose mode. Display column headers
nodeattrs(**kwargs)

Returns information about custom node attributes. https://www.elastic.co/guide/en/elasticsearch/reference/master/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
  • 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
nodes(**kwargs)

Returns basic statistics about performance of cluster nodes. https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodes.html

Parameters:
  • bytes – The unit in which to display byte values Valid choices: b, k, kb, m, mb, g, gb, t, tb, p, pb
  • 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
  • local – Calculate the selected nodes using the local cluster state rather than 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
  • time – The unit in which to display time values Valid choices: d, h, m, s, ms, micros, nanos
  • v – Verbose mode. Display column headers
pending_tasks(**kwargs)

Returns a concise representation of the cluster pending tasks. https://www.elastic.co/guide/en/elasticsearch/reference/master/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
  • 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
  • time – The unit in which to display time values Valid choices: d, h, m, s, ms, micros, nanos
  • v – Verbose mode. Display column headers
plugins(**kwargs)

Returns information about installed plugins across nodes node. https://www.elastic.co/guide/en/elasticsearch/reference/master/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
  • 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
recovery(**kwargs)

Returns information about index shard recoveries, both on-going completed. https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-recovery.html

Parameters:
  • index – Comma-separated list or wildcard expression of index names to limit the returned information
  • active_only – If true, the response only includes ongoing shard recoveries
  • bytes – The unit in which to display byte values Valid choices: b, k, kb, m, mb, g, gb, t, tb, p, pb
  • detailed – If true, the response includes detailed information about shard recoveries
  • 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
  • s – Comma-separated list of column names or column aliases to sort by
  • time – The unit in which to display time values Valid choices: d, h, m, s, ms, micros, nanos
  • v – Verbose mode. Display column headers
repositories(**kwargs)

Returns information about snapshot repositories registered in the cluster. https://www.elastic.co/guide/en/elasticsearch/reference/master/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
  • local – Return local information, do not retrieve the state from master node
  • 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
segments(**kwargs)

Provides low-level information about the segments in the shards of an index. https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-segments.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: 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
  • s – Comma-separated list of column names or column aliases to sort by
  • v – Verbose mode. Display column headers
shards(**kwargs)

Provides a detailed view of shard allocation on nodes. https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-shards.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: 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
  • 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
  • time – The unit in which to display time values Valid choices: d, h, m, s, ms, micros, nanos
  • v – Verbose mode. Display column headers
snapshots(**kwargs)

Returns all snapshots in a specific repository. https://www.elastic.co/guide/en/elasticsearch/reference/master/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
  • ignore_unavailable – Set to true to ignore unavailable snapshots
  • master_timeout – Explicit operation timeout for connection to master node
  • s – Comma-separated list of column names or column aliases to sort by
  • time – The unit in which to display time values Valid choices: d, h, m, s, ms, micros, nanos
  • v – Verbose mode. Display column headers
tasks(**kwargs)

Returns information about the tasks currently executing on one or more nodes in the cluster. https://www.elastic.co/guide/en/elasticsearch/reference/master/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
  • 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_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
  • time – The unit in which to display time values Valid choices: d, h, m, s, ms, micros, nanos
  • v – Verbose mode. Display column headers
templates(**kwargs)

Returns information about existing templates. https://www.elastic.co/guide/en/elasticsearch/reference/master/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
  • 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
thread_pool(**kwargs)

Returns cluster-wide thread pool statistics per node. By default the active, queue and rejected statistics are returned for all thread pools. https://www.elastic.co/guide/en/elasticsearch/reference/master/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
  • 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: , k, m, g, t, p
  • v – Verbose mode. Display column headers
transforms(**kwargs)

Gets configuration and usage information about transforms. https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-transforms.html

Parameters:
  • transform_id – The id of the transform for which to get stats. ‘_all’ or ‘*’ implies all transforms
  • allow_no_match – Whether to ignore if a wildcard expression matches no transforms. (This includes _all string or when no transforms have been specified)
  • format – a short version of the Accept header, e.g. json, yaml
  • from – skips a number of transform configs, defaults to 0
  • h – Comma-separated list of column names to display
  • help – Return help information
  • s – Comma-separated list of column names or column aliases to sort by
  • size – specifies a max number of transforms to get, defaults to 100
  • time – The unit in which to display time values Valid choices: d, h, m, s, ms, micros, nanos
  • v – Verbose mode. Display column headers

Snapshot

class elasticsearch.client.SnapshotClient(client)
cleanup_repository(**kwargs)

Removes stale data from repository. https://www.elastic.co/guide/en/elasticsearch/reference/master/clean-up-snapshot-repo-api.html

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

Creates a snapshot in a repository. https://www.elastic.co/guide/en/elasticsearch/reference/master/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
create_repository(**kwargs)

Creates a repository. https://www.elastic.co/guide/en/elasticsearch/reference/master/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(**kwargs)

Deletes a snapshot. https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html

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

Deletes a repository. https://www.elastic.co/guide/en/elasticsearch/reference/master/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(**kwargs)

Returns information about a snapshot. https://www.elastic.co/guide/en/elasticsearch/reference/master/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(**kwargs)

Returns information about a repository. https://www.elastic.co/guide/en/elasticsearch/reference/master/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(**kwargs)

Restores a snapshot. https://www.elastic.co/guide/en/elasticsearch/reference/master/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
status(**kwargs)

Returns information about the status of a snapshot. https://www.elastic.co/guide/en/elasticsearch/reference/master/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(**kwargs)

Verifies a repository. https://www.elastic.co/guide/en/elasticsearch/reference/master/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(**kwargs)

Cancels a task, if it can be cancelled through an API. https://www.elastic.co/guide/en/elasticsearch/reference/master/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.
  • nodes – 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_task_id – Cancel tasks with specified parent task id (node_id:task_number). Set to -1 to cancel all.
get(**kwargs)

Returns information about a task. https://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html

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

Returns a list of tasks. https://www.elastic.co/guide/en/elasticsearch/reference/master/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 Valid choices: nodes, parents, none Default: nodes
  • nodes – 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_task_id – Return tasks with specified parent task id (node_id:task_number). Set to -1 to return all.
  • timeout – Explicit operation timeout
  • wait_for_completion – Wait for the matching tasks to complete (default: false)