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(body, index=None, doc_type=None, params=None, headers=None)

Allows to perform multiple index/update/delete operations in a single request.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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

  • require_alias – Sets require_alias for all incoming documents. Defaults to unset (false)

  • 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(body=None, scroll_id=None, params=None, headers=None)

Explicitly clears the search context for a scroll.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/clear-scroll-api.html

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

close()

Closes the Transport and all internal connections

close_point_in_time(body=None, params=None, headers=None)

Close a point in time

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/point-in-time-api.html

Parameters

body – a point-in-time id to close

count(body=None, index=None, doc_type=None, params=None, headers=None)

Returns number of documents matching a query.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(index, id, body, doc_type=None, params=None, headers=None)

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/7.17/docs-index_.html

Parameters
  • index – The name of the index

  • id – Document ID

  • document – 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(index, id, doc_type=None, params=None, headers=None)

Removes a document from the index.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(index, body, doc_type=None, params=None, headers=None)

Deletes documents matching the provided query.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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

  • 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(task_id, params=None, headers=None)

Changes the number of requests per second for a particular Delete By Query operation.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(id, params=None, headers=None)

Deletes a script.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/modules-scripting.html

Parameters
  • id – Script ID

  • master_timeout – Specify timeout for connection to master

  • timeout – Explicit operation timeout

exists(index, id, doc_type=None, params=None, headers=None)

Returns information about whether a document exists in an index.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(index, id, doc_type=None, params=None, headers=None)

Returns information about whether a document source exists in an index.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(index, id, body=None, doc_type=None, params=None, headers=None)

Returns information about why a specific matches (or doesn’t match) a query.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(body=None, index=None, params=None, headers=None)

Returns the information about the capabilities of fields among multiple indices.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/search-field-caps.html

Parameters
  • body – An index filter specified with the Query DSL

  • 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(index, id, doc_type=None, params=None, headers=None)

Returns a document.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/docs-get.html

Parameters
  • index – Name of the index that contains the document.

  • id – Unique identifier of the document.

  • 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 comma-separated list of source fields to exclude in the response.

  • _source_includes – A comma-separated list of source fields to include in the response.

  • preference – Specifies the node or shard the operation should be performed on. Random by default.

  • realtime – Boolean) If true, the request is real-time as opposed to near-real-time. Default: True

  • refresh – If true, Elasticsearch refreshes the affected shards to make this operation visible to search. If false, do nothing with refreshes.

  • routing – Target the specified primary shard.

  • stored_fields – A comma-separated list of stored fields to return in the response

  • version – Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed.

  • version_type – Specific version type: internal, external, external_gte. Valid choices: internal, external, external_gte, force

get_script(id, params=None, headers=None)

Returns a script.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/modules-scripting.html

Parameters
  • id – Script ID

  • master_timeout – Specify timeout for connection to master

get_script_context(params=None, headers=None)

Returns all script contexts.

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

get_script_languages(params=None, headers=None)

Returns available script types, languages and contexts

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/modules-scripting.html

get_source(index, id, doc_type=None, params=None, headers=None)

Returns the source of a document.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(index, body, doc_type=None, id=None, params=None, headers=None)

Creates or updates a document in an index.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/docs-index_.html

Parameters
  • index – The name of the index

  • document – 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

  • require_alias – When true, requires destination to be an alias. Default is false

  • 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(params=None, headers=None)

Returns basic information about the cluster.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/index.html

mget(body, index=None, doc_type=None, params=None, headers=None)

Allows to get multiple documents in one request.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(body, index=None, doc_type=None, params=None, headers=None)

Allows to execute several search operations in one request.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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, dfs_query_then_fetch

  • typed_keys – Specify whether aggregation and suggester names should be prefixed by their respective types in the response

msearch_template(body, index=None, doc_type=None, params=None, headers=None)

Allows to execute several search template operations in one request.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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, dfs_query_then_fetch

  • typed_keys – Specify whether aggregation and suggester names should be prefixed by their respective types in the response

mtermvectors(body=None, index=None, doc_type=None, params=None, headers=None)

Returns multiple termvectors in one request.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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

open_point_in_time(index, params=None, headers=None)

Open a point in time that can be used in subsequent searches

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/point-in-time-api.html

Parameters
  • index – A comma-separated list of index names to open point in time; use _all or empty string to perform the operation on all indices

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

  • keep_alive – Specific the time to live for the point in time

  • preference – Specify the node or shard the operation should be performed on (default: random)

  • routing – Specific routing value

ping(params=None, headers=None)

Returns whether the cluster is running.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/index.html

put_script(id, body, context=None, params=None, headers=None)

Creates or updates a script.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/modules-scripting.html

Parameters
  • id – Script ID

  • body – The document

  • context – Script context

  • master_timeout – Specify timeout for connection to master

  • timeout – Explicit operation timeout

rank_eval(body, index=None, params=None, headers=None)

Allows to evaluate the quality of ranked search results over a set of typical search queries

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(body, params=None, headers=None)

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/7.17/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(task_id, params=None, headers=None)

Changes the number of requests per second for a particular Reindex operation.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(body=None, id=None, params=None, headers=None)

Allows to use the Mustache language to pre-render a search definition.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/render-search-template-api.html

Parameters
  • body – The search definition template and its params

  • id – The id of the stored search template

scripts_painless_execute(body=None, params=None, headers=None)

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

Warning

This API is experimental so may include breaking changes or be removed in a future version

Parameters

body – The script to execute

scroll(body=None, scroll_id=None, params=None, headers=None)

Allows to retrieve a large numbers of results from a single search request.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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

  • rest_total_hits_as_int – If true, the API response’s hit.total property is returned as an integer. If false, the API response’s hit.total property is returned as an object.

  • scroll – Period to retain the search context for scrolling.

search(body=None, index=None, doc_type=None, params=None, headers=None)

Returns results matching a query.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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 – Indicates which source fields are returned for matching documents. These fields are returned in the hits._source property of the search response.

  • _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

  • aggregations

  • aggs

  • 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

  • collapse

  • 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 – Array of wildcard (*) patterns. The request returns doc values for field names matching these patterns in the hits.fields property of the response.

  • 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 – If true, returns detailed information about score computation as part of a hit.

  • fields – Array of wildcard (*) patterns. The request returns values for field names matching these patterns in the hits.fields property of the response.

  • from – Starting document offset. By default, you cannot page through more than 10,000 hits using the from and size parameters. To page through more hits, use the search_after parameter.

  • highlight

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

  • indices_boost – Boosts the _score of documents from specified indices.

  • 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

  • min_compatible_shard_node – The minimum compatible version that all shards involved in search should have for this request to be successful

  • min_score – Minimum _score for matching documents. Documents with a lower _score are not included in the search results.

  • pit – Limits the search to a point in time (PIT). If you provide a PIT, you cannot specify an <index> in the request path.

  • post_filter

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

  • profile

  • q – Query in the Lucene query string syntax

  • query – Defines the search definition using the Query DSL.

  • request_cache – Specify if request cache should be used for this request or not, defaults to index level setting

  • rescore

  • 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

  • runtime_mappings – Defines one or more runtime fields in the search request. These fields take precedence over mapped fields with the same name.

  • script_fields – Retrieve a script evaluation (based on different fields) for each hit.

  • scroll – Specify how long a consistent view of the index should be maintained for scrolled search

  • search_after

  • search_type – Search operation type Valid choices: query_then_fetch, dfs_query_then_fetch

  • seq_no_primary_term – If true, returns sequence number and primary term of the last modification of each hit. See Optimistic concurrency control.

  • size – The number of hits to return. By default, you cannot page through more than 10,000 hits using the from and size parameters. To page through more hits, use the search_after parameter.

  • slice

  • sort

  • stats – Stats groups to associate with the search. Each group maintains a statistics aggregation for its associated searches. You can retrieve these stats using the indices stats API.

  • stored_fields – List of stored fields to return as part of a hit. If no fields are specified, no stored fields are included in the response. If this field is specified, the _source parameter defaults to false. You can pass _source: true to return both source fields and stored fields in the search response.

  • suggest

  • suggest_field – Specifies 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 – Maximum number of documents to collect for each shard. If a query reaches this limit, Elasticsearch terminates the query early. Elasticsearch collects documents before sorting. Defaults to 0, which does not terminate query execution early.

  • timeout – Specifies the period of time to wait for a response from each shard. If no response is received before the timeout expires, the request fails and returns an error. Defaults to no timeout.

  • track_scores – If true, calculate and return document scores, even if the scores are not used for sorting.

  • track_total_hits – Number of hits matching the query to count accurately. If true, the exact number of hits is returned at the cost of some performance. If false, the response does not include the total number of hits matching the query. Defaults to 10,000 hits.

  • typed_keys – Specify whether aggregation and suggester names should be prefixed by their respective types in the response

  • version – If true, returns document version as part of a hit.

search_mvt(index, field, zoom, x, y, body=None, params=None, headers=None)

Searches a vector tile for geospatial values. Returns results as a binary Mapbox vector tile.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/search-vector-tile-api.html

Warning

This API is experimental so may include breaking changes or be removed in a future version

Parameters
  • index – Comma-separated list of data streams, indices, or aliases to search

  • field – Field containing geospatial data to return

  • zoom – Zoom level for the vector tile to search

  • x – X coordinate for the vector tile to search

  • y – Y coordinate for the vector tile to search

  • body – Search request body.

  • aggs

    Sub-aggregations for the geotile_grid.

    Supports the following aggregation types: - avg - cardinality - max - min - sum

  • exact_bounds – If false, the meta layer’s feature is the bounding box of the tile. If true, the meta layer’s feature is a bounding box resulting from a geo_bounds aggregation. The aggregation runs on <field> values that intersect the <zoom>/<x>/<y> tile with wrap_longitude set to false. The resulting bounding box may be larger than the vector tile.

  • extent – Size, in pixels, of a side of the tile. Vector tiles are square with equal sides.

  • fields – Fields to return in the hits layer. Supports wildcards (*). This parameter does not support fields with array values. Fields with array values may return inconsistent results.

  • grid_precision – Additional zoom levels available through the aggs layer. For example, if <zoom> is 7 and grid_precision is 8, you can zoom in up to level 15. Accepts 0-8. If 0, results don’t include the aggs layer.

  • grid_type – Determines the geometry type for features in the aggs layer. In the aggs layer, each feature represents a geotile_grid cell. If ‘grid’ each feature is a Polygon of the cells bounding box. If ‘point’ each feature is a Point that is the centroid of the cell.

  • query – Query DSL used to filter documents for the search.

  • runtime_mappings – Defines one or more runtime fields in the search request. These fields take precedence over mapped fields with the same name.

  • size – Maximum number of features to return in the hits layer. Accepts 0-10000. If 0, results don’t include the hits layer.

  • sort – Sorts features in the hits layer. By default, the API calculates a bounding box for each feature. It sorts features based on this box’s diagonal length, from longest to shortest.

search_shards(index=None, params=None, headers=None)

Returns information about the indices and shards that a search request would be executed against.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(body, index=None, doc_type=None, params=None, headers=None)

Allows to use the Mustache language to pre-render a search definition.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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, dfs_query_then_fetch

  • typed_keys – Specify whether aggregation and suggester names should be prefixed by their respective types in the response

terms_enum(index, body=None, params=None, headers=None)

The terms enum API can be used to discover terms in the index that begin with the provided string. It is designed for low-latency look-ups used in auto- complete scenarios.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/search-terms-enum.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 – field name, string which is the prefix expected in matching terms, timeout and size for max number of results

termvectors(index, body=None, doc_type=None, id=None, params=None, headers=None)

Returns information and statistics about terms in the fields of a particular document.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(index, id, body, doc_type=None, params=None, headers=None)

Updates a document with a script or partial document.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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 – Set to false to disable source retrieval. You can also specify a comma-separated list of the fields you want to retrieve.

  • _source_excludes – Specify the source fields you want to exclude.

  • _source_includes – Specify the source fields you want to retrieve.

  • detect_noop – Set to false to disable setting ‘result’ in the response to ‘noop’ if no change to the document occurred.

  • doc – A partial update to an existing document.

  • doc_as_upsert – Set to true to use the contents of ‘doc’ as the value of ‘upsert’

  • if_primary_term – Only perform the operation if the document has this primary term.

  • if_seq_no – Only perform the operation if the document has this sequence number.

  • lang – The script language. Default: painless

  • refresh – If ‘true’, Elasticsearch refreshes 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’ do nothing with refreshes. Valid choices: true, false, wait_for Default: false

  • require_alias – If true, the destination must be an index alias.

  • retry_on_conflict – Specify how many times should the operation be retried when a conflict occurs.

  • routing – Custom value used to route operations to a specific shard.

  • script – Script to execute to update the document.

  • scripted_upsert – Set to true to execute the script whether or not the document exists.

  • timeout – Period to wait for dynamic mapping updates and active shards. This guarantees Elasticsearch waits for at least the timeout before failing. The actual wait time could be longer, particularly when multiple waits occur. Default: 1m

  • upsert – If the document does not already exist, the contents of ‘upsert’ are inserted as a new document. If the document exists, the ‘script’ is executed.

  • wait_for_active_shards – The number of shard copies that must be active before proceeding with the operations. Set to ‘all’ or any positive integer up to the total number of shards in the index (number_of_replicas+1). Defaults to 1 meaning the primary shard. Default: 1

update_by_query(index, body=None, doc_type=None, params=None, headers=None)

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/7.17/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

  • 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(task_id, params=None, headers=None)

Changes the number of requests per second for a particular Update By Query operation.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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.

Autoscaling

class elasticsearch.client.AutoscalingClient(client)
delete_autoscaling_policy(name, params=None, headers=None)

Deletes an autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/autoscaling-delete-autoscaling-policy.html

Parameters

name – the name of the autoscaling policy

get_autoscaling_capacity(params=None, headers=None)

Gets the current autoscaling capacity based on the configured autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/autoscaling-get-autoscaling-capacity.html

get_autoscaling_policy(name, params=None, headers=None)

Retrieves an autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/autoscaling-get-autoscaling-policy.html

Parameters

name – the name of the autoscaling policy

put_autoscaling_policy(name, body, params=None, headers=None)

Creates a new autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/autoscaling-put-autoscaling-policy.html

Parameters
  • name – the name of the autoscaling policy

  • body – the specification of the autoscaling policy

Cat

class elasticsearch.client.CatClient(client)
aliases(name=None, params=None, headers=None)

Shows information about currently configured aliases to indices including filter and routing infos.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(node_id=None, params=None, headers=None)

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/7.17/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(index=None, params=None, headers=None)

Provides quick access to the document count of the entire cluster, or individual indices.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(fields=None, params=None, headers=None)

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/7.17/cat-fielddata.html

Parameters
  • fields – A comma-separated list of fields to return the fielddata size

  • bytes – The unit in which to display byte values Valid choices: 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(params=None, headers=None)

Returns a concise representation of the cluster health.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(params=None, headers=None)

Returns help for the Cat APIs.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/cat.html

Parameters
  • help – Return help information

  • s – Comma-separated list of column names or column aliases to sort by

indices(index=None, params=None, headers=None)

Returns information about indices: number of primaries and replicas, document counts, disk size, …

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(params=None, headers=None)

Returns information about the master node.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(id=None, params=None, headers=None)

Gets configuration and usage information about data frame analytics jobs.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(datafeed_id=None, params=None, headers=None)

Gets configuration and usage information about datafeeds.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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)

  • allow_no_match – 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(job_id=None, params=None, headers=None)

Gets configuration and usage information about anomaly detection jobs.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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)

  • allow_no_match – 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(model_id=None, params=None, headers=None)

Gets configuration and usage information about inference trained models.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(params=None, headers=None)

Returns information about custom node attributes.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(params=None, headers=None)

Returns basic statistics about performance of cluster nodes.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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

  • include_unloaded_segments – If set to true segment stats will include stats for segments that are not currently loaded into memory

  • 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(params=None, headers=None)

Returns a concise representation of the cluster pending tasks.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(params=None, headers=None)

Returns information about installed plugins across nodes node.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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

  • include_bootstrap – Include bootstrap plugins in the response

  • 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(index=None, params=None, headers=None)

Returns information about index shard recoveries, both on-going completed.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(params=None, headers=None)

Returns information about snapshot repositories registered in the cluster.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(index=None, params=None, headers=None)

Provides low-level information about the segments in the shards of an index.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(index=None, params=None, headers=None)

Provides a detailed view of shard allocation on nodes.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(repository=None, params=None, headers=None)

Returns all snapshots in a specific repository.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(params=None, headers=None)

Returns information about the tasks currently executing on one or more nodes in the cluster.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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

  • 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.

  • 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(name=None, params=None, headers=None)

Returns information about existing templates.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(thread_pool_patterns=None, params=None, headers=None)

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/7.17/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(transform_id=None, params=None, headers=None)

Gets configuration and usage information about transforms.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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

Cross-Cluster Replication (CCR)

class elasticsearch.client.CcrClient(client)
delete_auto_follow_pattern(name, params=None, headers=None)

Deletes auto-follow patterns.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ccr-delete-auto-follow-pattern.html

Parameters

name – The name of the auto follow pattern.

follow(index, body, params=None, headers=None)

Creates a new follower index configured to follow the referenced leader index.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ccr-put-follow.html

Parameters
  • index – The name of the follower index

  • body – The name of the leader index and other optional ccr related parameters

  • wait_for_active_shards – Sets the number of shard copies that must be active before returning. Defaults to 0. 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) Default: 0

follow_info(index, params=None, headers=None)

Retrieves information about all follower indices, including parameters and status for each follower index

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ccr-get-follow-info.html

Parameters

index – A comma-separated list of index patterns; use _all to perform the operation on all indices

follow_stats(index, params=None, headers=None)

Retrieves follower stats. return shard-level stats about the following tasks associated with each shard for the specified indices.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ccr-get-follow-stats.html

Parameters

index – A comma-separated list of index patterns; use _all to perform the operation on all indices

forget_follower(index, body, params=None, headers=None)

Removes the follower retention leases from the leader.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ccr-post-forget-follower.html

Parameters
  • index – the name of the leader index for which specified follower retention leases should be removed

  • body – the name and UUID of the follower index, the name of the cluster containing the follower index, and the alias from the perspective of that cluster for the remote cluster containing the leader index

get_auto_follow_pattern(name=None, params=None, headers=None)

Gets configured auto-follow patterns. Returns the specified auto-follow pattern collection.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ccr-get-auto-follow-pattern.html

Parameters

name – The name of the auto follow pattern.

pause_auto_follow_pattern(name, params=None, headers=None)

Pauses an auto-follow pattern

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ccr-pause-auto-follow-pattern.html

Parameters

name – The name of the auto follow pattern that should pause discovering new indices to follow.

pause_follow(index, params=None, headers=None)

Pauses a follower index. The follower index will not fetch any additional operations from the leader index.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ccr-post-pause-follow.html

Parameters

index – The name of the follower index that should pause following its leader index.

put_auto_follow_pattern(name, body, params=None, headers=None)

Creates a new named collection of auto-follow patterns against a specified remote cluster. Newly created indices on the remote cluster matching any of the specified patterns will be automatically configured as follower indices.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ccr-put-auto-follow-pattern.html

Parameters
  • name – The name of the auto follow pattern.

  • body – The specification of the auto follow pattern

resume_auto_follow_pattern(name, params=None, headers=None)

Resumes an auto-follow pattern that has been paused

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ccr-resume-auto-follow-pattern.html

Parameters

name – The name of the auto follow pattern to resume discovering new indices to follow.

resume_follow(index, body=None, params=None, headers=None)

Resumes a follower index that has been paused

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ccr-post-resume-follow.html

Parameters
  • index – The name of the follow index to resume following.

  • body – The name of the leader index and other optional ccr related parameters

stats(params=None, headers=None)

Gets all stats related to cross-cluster replication.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ccr-get-stats.html

unfollow(index, params=None, headers=None)

Stops the following task associated with a follower index and removes index metadata and settings associated with cross-cluster replication.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ccr-post-unfollow.html

Parameters

index – The name of the follower index that should be turned into a regular index.

Cluster

class elasticsearch.client.ClusterClient(client)
allocation_explain(body=None, params=None, headers=None)

Provides explanations for shard allocations in the cluster.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/cluster-allocation-explain.html

Parameters
  • body – The index, shard, and primary flag to explain. Empty means ‘explain a randomly-chosen 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(name, params=None, headers=None)

Deletes a component template

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-component-template.html

Parameters
  • name – The name of the template

  • master_timeout – Specify timeout for connection to master

  • timeout – Explicit operation timeout

delete_voting_config_exclusions(params=None, headers=None)

Clears cluster voting config exclusions.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/voting-config-exclusions.html

Parameters

wait_for_removal – Specifies whether to wait for all excluded nodes to be removed from the cluster before clearing the voting configuration exclusions list. Default: True

exists_component_template(name, params=None, headers=None)

Returns information about whether a particular component template exist

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-component-template.html

Parameters
  • name – The name of the template

  • 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_component_template(name=None, params=None, headers=None)

Returns one or more component templates

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-component-template.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(params=None, headers=None)

Returns cluster settings.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/cluster-get-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(index=None, params=None, headers=None)

Returns basic information about the health of the cluster.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(params=None, headers=None)

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/7.17/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

post_voting_config_exclusions(params=None, headers=None)

Updates the cluster voting config exclusions by node ids or node names.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/voting-config-exclusions.html

Parameters
  • node_ids – A comma-separated list of the persistent ids of the nodes to exclude from the voting configuration. If specified, you may not also specify ?node_names.

  • node_names – A comma-separated list of the names of the nodes to exclude from the voting configuration. If specified, you may not also specify ?node_ids.

  • timeout – Explicit operation timeout Default: 30s

put_component_template(name, body, params=None, headers=None)

Creates or updates a component template

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-component-template.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(body, params=None, headers=None)

Updates the cluster settings.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(params=None, headers=None)

Returns the information about configured remote clusters.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/cluster-remote-info.html

reroute(body=None, params=None, headers=None)

Allows to manually change the allocation of individual shards in the cluster.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(metric=None, index=None, params=None, headers=None)

Returns a comprehensive information about the state of the cluster.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(node_id=None, params=None, headers=None)

Returns high-level overview of cluster statistics.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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

Dangling Indices

class elasticsearch.client.DanglingIndicesClient(client)
delete_dangling_index(index_uuid, params=None, headers=None)

Deletes the specified dangling index

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/modules-gateway-dangling-indices.html

Parameters
  • index_uuid – The UUID of the dangling index

  • accept_data_loss – Must be set to true in order to delete the dangling index

  • master_timeout – Specify timeout for connection to master

  • timeout – Explicit operation timeout

import_dangling_index(index_uuid, params=None, headers=None)

Imports the specified dangling index

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/modules-gateway-dangling-indices.html

Parameters
  • index_uuid – The UUID of the dangling index

  • accept_data_loss – Must be set to true in order to import the dangling index

  • master_timeout – Specify timeout for connection to master

  • timeout – Explicit operation timeout

list_dangling_indices(params=None, headers=None)

Returns all dangling indices.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/modules-gateway-dangling-indices.html

Enrich Policies

class elasticsearch.client.EnrichClient(client)
delete_policy(name, params=None, headers=None)

Deletes an existing enrich policy and its enrich index.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/delete-enrich-policy-api.html

Parameters

name – The name of the enrich policy

execute_policy(name, params=None, headers=None)

Creates the enrich index for an existing enrich policy.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/execute-enrich-policy-api.html

Parameters
  • name – The name of the enrich policy

  • wait_for_completion – Should the request should block until the execution is complete. Default: True

get_policy(name=None, params=None, headers=None)

Gets information about an enrich policy.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/get-enrich-policy-api.html

Parameters

name – A comma-separated list of enrich policy names

put_policy(name, body, params=None, headers=None)

Creates a new enrich policy.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/put-enrich-policy-api.html

Parameters
  • name – The name of the enrich policy

  • body – The enrich policy to register

stats(params=None, headers=None)

Gets enrich coordinator statistics and information about enrich policies that are currently executing.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/enrich-stats-api.html

Event Query Language (EQL)

class elasticsearch.client.EqlClient(client)
delete(id, params=None, headers=None)

Deletes an async EQL search by ID. If the search is still running, the search request will be cancelled. Otherwise, the saved search results are deleted.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/eql-search-api.html

Parameters

id – The async search ID

get(id, params=None, headers=None)

Returns async results from previously executed Event Query Language (EQL) search

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/eql-search-api.html

Parameters
  • id – The async search ID

  • keep_alive – Update the time interval in which the results (partial or final) for this search will be available Default: 5d

  • wait_for_completion_timeout – Specify the time that the request should block waiting for the final response

get_status(id, params=None, headers=None)

Returns the status of a previously submitted async or stored Event Query Language (EQL) search

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/eql-search-api.html

Parameters

id – The async search ID

search(index, body, params=None, headers=None)

Returns results matching a query expressed in Event Query Language (EQL)

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/eql-search-api.html

Parameters
  • index – The name of the index to scope the operation

  • body – Eql request body. Use the query to limit the query scope.

  • keep_alive – Update the time interval in which the results (partial or final) for this search will be available Default: 5d

  • keep_on_completion – Control whether the response should be stored in the cluster if it completed within the provided [wait_for_completion] time (default: false)

  • wait_for_completion_timeout – Specify the time that the request should block waiting for the final response

Snapshottable Features

class elasticsearch.client.FeaturesClient(client)
get_features(params=None, headers=None)

Gets a list of features which can be included in snapshots using the feature_states field when creating a snapshot

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/get-features-api.html

Parameters

master_timeout – Explicit operation timeout for connection to master node

reset_features(params=None, headers=None)

Resets the internal state of features, usually by deleting system indices

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/modules-snapshots.html

Warning

This API is experimental so may include breaking changes or be removed in a future version

Fleet

class elasticsearch.client.FleetClient(client)
global_checkpoints(index, params=None, headers=None)

Returns the current global checkpoints for an index. This API is design for internal use by the fleet server project.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/get-global-checkpoints.html

Parameters
  • index – The name of the index.

  • checkpoints – Comma separated list of checkpoints

  • timeout – Timeout to wait for global checkpoint to advance Default: 30s

  • wait_for_advance – Whether to wait for the global checkpoint to advance past the specified current checkpoints Default: false

  • wait_for_index – Whether to wait for the target index to exist and all primary shards be active Default: false

msearch(body, index=None, params=None, headers=None)

Multi Search API where the search will only be executed after specified checkpoints are available due to a refresh. This API is designed for internal use by the fleet server project.

Warning

This API is experimental so may include breaking changes or be removed in a future version

Parameters
  • body – The request definitions (metadata-fleet search request definition pairs), separated by newlines

  • index – The index name to use as the default

search(index, body=None, params=None, headers=None)

Search API where the search will only be executed after specified checkpoints are available due to a refresh. This API is designed for internal use by the fleet server project.

Warning

This API is experimental so may include breaking changes or be removed in a future version

Parameters
  • index – The index name to search.

  • body – The search definition using the Query DSL

  • allow_partial_search_results – Indicate if an error should be returned if there is a partial search failure or timeout Default: True

  • wait_for_checkpoints – Comma separated list of checkpoints, one per shard

  • wait_for_checkpoints_timeout – Explicit wait_for_checkpoints timeout

Graph Explore

class elasticsearch.client.GraphClient(client)
explore(index, body=None, doc_type=None, params=None, headers=None)

Explore extracted and summarized information about the documents and terms in an index.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/graph-explore-api.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 – Graph Query DSL

  • doc_type – A comma-separated list of document types to search; leave empty to perform the operation on all types

  • routing – Specific routing value

  • timeout – Explicit operation timeout

Index Lifecycle Management (ILM)

class elasticsearch.client.IlmClient(client)
delete_lifecycle(policy, params=None, headers=None)

Deletes the specified lifecycle policy definition. A currently used policy cannot be deleted.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ilm-delete-lifecycle.html

Parameters

policy – The name of the index lifecycle policy

explain_lifecycle(index, params=None, headers=None)

Retrieves information about the index’s current lifecycle state, such as the currently executing phase, action, and step.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ilm-explain-lifecycle.html

Parameters
  • index – The name of the index to explain

  • only_errors – filters the indices included in the response to ones in an ILM error state, implies only_managed

  • only_managed – filters the indices included in the response to ones managed by ILM

get_lifecycle(policy=None, params=None, headers=None)

Returns the specified policy definition. Includes the policy version and last modified date.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ilm-get-lifecycle.html

Parameters

policy – The name of the index lifecycle policy

get_status(params=None, headers=None)

Retrieves the current index lifecycle management (ILM) status.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ilm-get-status.html

migrate_to_data_tiers(body=None, params=None, headers=None)

Migrates the indices and ILM policies away from custom node attribute allocation routing to data tiers routing

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ilm-migrate-to-data-tiers.html

Parameters
  • body – Optionally specify a legacy index template name to delete and optionally specify a node attribute name used for index shard routing (defaults to “data”)

  • dry_run – If set to true it will simulate the migration, providing a way to retrieve the ILM policies and indices that need to be migrated. The default is false

move_to_step(index, body=None, params=None, headers=None)

Manually moves an index into the specified step and executes that step.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ilm-move-to-step.html

Parameters
  • index – The name of the index whose lifecycle step is to change

  • body – The new lifecycle step to move to

put_lifecycle(policy, body=None, params=None, headers=None)

Creates a lifecycle policy

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ilm-put-lifecycle.html

Parameters
  • policy – The name of the index lifecycle policy

  • body – The lifecycle policy definition to register

remove_policy(index, params=None, headers=None)

Removes the assigned lifecycle policy and stops managing the specified index

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ilm-remove-policy.html

Parameters

index – The name of the index to remove policy on

retry(index, params=None, headers=None)

Retries executing the policy for an index that is in the ERROR step.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ilm-retry-policy.html

Parameters

index – The name of the indices (comma-separated) whose failed lifecycle step is to be retry

start(params=None, headers=None)

Start the index lifecycle management (ILM) plugin.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ilm-start.html

stop(params=None, headers=None)

Halts all lifecycle management operations and stops the index lifecycle management (ILM) plugin

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ilm-stop.html

Indices

class elasticsearch.client.IndicesClient(client)
add_block(index, block, params=None, headers=None)

Adds a block to an index.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/index-modules-blocks.html

Parameters
  • index – A comma separated list of indices to add a block to

  • block – The block to add (one of read, write, read_only or metadata)

  • 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

analyze(body=None, index=None, params=None, headers=None)

Performs the analysis process on a text and return the tokens breakdown of the text.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(index=None, params=None, headers=None)

Clears all or specific caches for one or more indices.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(index, target, body=None, params=None, headers=None)

Clones an index

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(index, params=None, headers=None)

Closes an index.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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. Set to index-setting to wait according to the index setting index.write.wait_for_active_shards, or all to wait for all shards, or an integer. Defaults to 0.

create(index, body=None, params=None, headers=None)

Creates an index with optional settings and mappings.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-create-index.html

Parameters
  • index – The name of the index

  • body – The configuration for the index (settings and mappings)

  • aliases

  • include_type_name – Whether a type should be expected in the body of the mappings.

  • mappings – Mapping for fields in the index. If specified, this mapping can include: - Field names - Field data types - Mapping parameters

  • master_timeout – Specify timeout for connection to master

  • settings

  • timeout – Explicit operation timeout

  • wait_for_active_shards – Set the number of active shards to wait for before the operation returns.

create_data_stream(name, params=None, headers=None)

Creates a data stream

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

Parameters

name – The name of the data stream

data_streams_stats(name=None, params=None, headers=None)

Provides statistics on operations happening in a data stream.

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

Parameters

name – A comma-separated list of data stream names; use _all or empty string to perform the operation on all data streams

delete(index, params=None, headers=None)

Deletes an index.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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, closed, or hidden indices Valid choices: open, closed, hidden, none, all Default: open,closed

  • ignore_unavailable – Ignore unavailable indexes (default: false)

  • master_timeout – Specify timeout for connection to master

  • timeout – Explicit operation timeout

delete_alias(index, name, params=None, headers=None)

Deletes an alias.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(name, params=None, headers=None)

Deletes a data stream.

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

Parameters
  • name – A comma-separated list of data streams to delete; use * to delete all data streams

  • expand_wildcards – Whether wildcard expressions should get expanded to open or closed indices (default: open) Valid choices: open, closed, hidden, none, all Default: open

delete_index_template(name, params=None, headers=None)

Deletes an index template.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-templates.html

Parameters
  • name – The name of the template

  • master_timeout – Specify timeout for connection to master

  • timeout – Explicit operation timeout

delete_template(name, params=None, headers=None)

Deletes an index template.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-templates.html

Parameters
  • name – The name of the template

  • master_timeout – Specify timeout for connection to master

  • timeout – Explicit operation timeout

disk_usage(index, params=None, headers=None)

Analyzes the disk usage of each field of an index or data stream

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-disk-usage.html

Warning

This API is experimental so may include breaking changes or be removed in a future version

Parameters
  • index – Comma-separated list of indices or data streams to analyze the disk usage

  • 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 – Whether flush or not before analyzing the index disk usage. Defaults to true

  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)

  • run_expensive_tasks – Must be set to [true] in order for the task to be performed. Defaults to false.

exists(index, params=None, headers=None)

Returns information about whether a particular index exists.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(name, index=None, params=None, headers=None)

Returns information about whether a particular alias exists.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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_index_template(name, params=None, headers=None)

Returns information about whether a particular index template exists.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-templates.html

Parameters
  • name – The name of the template

  • flat_settings – Return settings in flat format (default: false)

  • local – Return local information, do not retrieve the state from master node (default: false)

  • master_timeout – Explicit operation timeout for connection to master node

exists_template(name, params=None, headers=None)

Returns information about whether a particular index template exists.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(index, doc_type, params=None, headers=None)

Returns information about whether a particular document type exists. (DEPRECATED)

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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)

field_usage_stats(index, params=None, headers=None)

Returns the field usage stats for each field of an index

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/field-usage-stats.html

Warning

This API is experimental so may include breaking changes or be removed in a future version

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 fields to include in the stats if only a subset of fields should be returned (supports wildcards)

  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)

flush(index=None, params=None, headers=None)

Performs the flush operation on one or more indices.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(index=None, params=None, headers=None)

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/7.17/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(index=None, params=None, headers=None)

Performs the force merge operation on one or more indices.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(index, params=None, headers=None)

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/7.17/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(index, params=None, headers=None)

Returns information about one or more indices.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-get-index.html

Parameters
  • index – Comma-separated list of data streams, indices, and index aliases used to limit the request. Wildcard expressions (*) are supported.

  • allow_no_indices – Ignore if a wildcard expression resolves to no concrete indices (default: false) Default: True

  • expand_wildcards – Type of index that wildcard expressions can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as open,hidden. Valid choices: open, closed, hidden, none, all Default: open

  • flat_settings – If true, returns settings in flat format.

  • ignore_unavailable – If false, requests that target a missing index return an error.

  • include_defaults – If true, return all default settings in the response.

  • include_type_name – If true, a mapping type is expected in the body of mappings.

  • local – If true, the request retrieves information from the local node only. Defaults to false, which means information is retrieved from the master node.

  • master_timeout – Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Default: 30s

get_alias(index=None, name=None, params=None, headers=None)

Returns an alias.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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_stream(name=None, params=None, headers=None)

Returns data streams.

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

Parameters
  • name – A comma-separated list of data streams to get; use * to get all data streams

  • expand_wildcards – Whether wildcard expressions should get expanded to open or closed indices (default: open) Valid choices: open, closed, hidden, none, all Default: open

get_field_mapping(fields, index=None, doc_type=None, params=None, headers=None)

Returns mapping for one or more fields.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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_index_template(name=None, params=None, headers=None)

Returns an index template.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-templates.html

Parameters
  • name – A pattern that returned template names must match

  • flat_settings – Return settings in flat format (default: false)

  • local – Return local information, do not retrieve the state from master node (default: false)

  • master_timeout – Explicit operation timeout for connection to master node

get_mapping(index=None, doc_type=None, params=None, headers=None)

Returns mappings for one or more indices.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(index=None, name=None, params=None, headers=None)

Returns settings for one or more indices.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(name=None, params=None, headers=None)

Returns an index template.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(index=None, params=None, headers=None)

DEPRECATED Returns a progress status of current upgrade.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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)

migrate_to_data_stream(name, params=None, headers=None)

Migrates an alias to a data stream

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

Parameters

name – The name of the alias to migrate

modify_data_stream(body, params=None, headers=None)

Modifies a data stream

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

Parameters

body – The data stream modifications

open(index, params=None, headers=None)

Opens an index.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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.

promote_data_stream(name, params=None, headers=None)

Promotes a data stream from a replicated data stream managed by CCR to a regular data stream

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

Parameters

name – The name of the data stream

put_alias(index, name, body=None, params=None, headers=None)

Creates or updates an alias.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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_index_template(name, body, params=None, headers=None)

Creates or updates an index template.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-templates.html

Parameters
  • name – The name of the template

  • body – The template definition

  • cause – User defined reason for creating/updating the index template

  • 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

put_mapping(body, index=None, doc_type=None, params=None, headers=None)

Updates the index mappings.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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

  • write_index_only – When true, applies mappings only to the write index of an alias or data stream

put_settings(body, index=None, params=None, headers=None)

Updates the index settings.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(name, body, params=None, headers=None)

Creates or updates an index template.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(index=None, params=None, headers=None)

Returns information about ongoing index shard recoveries.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(index=None, params=None, headers=None)

Performs the refresh operation in one or more indices.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(index, params=None, headers=None)

Reloads an index’s search analyzers and their resources.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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)

resolve_index(name, params=None, headers=None)

Returns information about any matching indices, aliases, and data streams

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-resolve-index-api.html

Parameters
  • name – A comma-separated list of names or wildcard expressions

  • expand_wildcards – Whether wildcard expressions should get expanded to open or closed indices (default: open) Valid choices: open, closed, hidden, none, all Default: open

rollover(alias, body=None, new_index=None, params=None, headers=None)

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/7.17/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(index=None, params=None, headers=None)

Provides low-level information about segments in a Lucene index.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(index=None, params=None, headers=None)

Provides store information for shard copies of indices.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-shards-stores.html

Parameters
  • index – List of data streams, indices, and aliases used to limit the request.

  • allow_no_indices – If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. This behavior applies even if the request targets other open indices.

  • expand_wildcards – Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Valid choices: open, closed, hidden, none, all Default: open

  • ignore_unavailable – If true, missing or closed indices are not included in the response.

  • status – List of shard health statuses used to limit the request. Valid choices: green, yellow, red, all

shrink(index, target, body=None, params=None, headers=None)

Allow to shrink an existing index into a new index with fewer primary shards.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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.

simulate_index_template(name, body=None, params=None, headers=None)

Simulate matching the given index name against the index templates in the system

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-templates.html

Parameters
  • name – The name of the index (it must be a concrete index name)

  • body – New index template definition, which will be included in the simulation, as if it already exists in the system

  • cause – User defined reason for dry-run creating the new template for simulation purposes

  • create – Whether the index template we optionally defined in the body should only be dry-run added if new or can also replace an existing one

  • master_timeout – Specify timeout for connection to master

simulate_template(body=None, name=None, params=None, headers=None)

Simulate resolving the given template name or body

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-templates.html

Parameters
  • body – New index template definition to be simulated, if no index template name is specified

  • name – The name of the index template

  • cause – User defined reason for dry-run creating the new template for simulation purposes

  • create – Whether the index template we optionally defined in the body should only be dry-run added if new or can also replace an existing one

  • master_timeout – Specify timeout for connection to master

split(index, target, body=None, params=None, headers=None)

Allows you to split an existing index into a new index with more primary shards.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(index=None, metric=None, params=None, headers=None)

Provides statistics on operations happening in an index.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-stats.html

Parameters
  • index – A comma-separated list of index names; use _all or empty string to perform the operation on all indices

  • metric – Limit the information returned the specific metrics.

  • completion_fields – A comma-separated list of fields for fielddata and suggest index metric (supports wildcards)

  • 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(index, params=None, headers=None)

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/7.17/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(body, params=None, headers=None)

Updates index aliases.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-aliases.html

Parameters
  • body – The definition of actions to perform

  • master_timeout – Specify timeout for connection to master

  • timeout – Request timeout

upgrade(index=None, params=None, headers=None)

DEPRECATED Upgrades to the current version of Lucene.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(body=None, index=None, doc_type=None, params=None, headers=None)

Allows a user to validate a potentially expensive query without executing it.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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 Pipelines

class elasticsearch.client.IngestClient(client)
delete_pipeline(id, params=None, headers=None)

Deletes a pipeline.

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

Parameters
  • id – Pipeline ID

  • master_timeout – Explicit operation timeout for connection to master node

  • timeout – Explicit operation timeout

geo_ip_stats(params=None, headers=None)

Returns statistical information about geoip databases

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/geoip-stats-api.html

get_pipeline(id=None, params=None, headers=None)

Returns a pipeline.

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

Parameters
  • id – Comma separated list of pipeline ids. Wildcards supported

  • master_timeout – Explicit operation timeout for connection to master node

  • summary – Return pipelines without their definitions (default: false)

processor_grok(params=None, headers=None)

Returns a list of the built-in patterns.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/grok-processor.html#grok-processor-rest-get

put_pipeline(id, body, params=None, headers=None)

Creates or updates a pipeline.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/put-pipeline-api.html

Parameters
  • id – Pipeline ID

  • body – The ingest definition

  • if_version – Required version for optimistic concurrency control for pipeline updates

  • master_timeout – Explicit operation timeout for connection to master node

  • timeout – Explicit operation timeout

simulate(body, id=None, params=None, headers=None)

Allows to simulate a pipeline with example documents.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/simulate-pipeline-api.html

Parameters
  • body – The simulate definition

  • id – Pipeline ID

  • verbose – Verbose mode. Display data output for each processor in executed pipeline

License

class elasticsearch.client.LicenseClient(client)
delete(params=None, headers=None)

Deletes licensing information for the cluster

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/delete-license.html

get(params=None, headers=None)

Retrieves licensing information for the cluster

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/get-license.html

Parameters
  • accept_enterprise – If the active license is an enterprise license, return type as ‘enterprise’ (default: false)

  • local – Return local information, do not retrieve the state from master node (default: false)

get_basic_status(params=None, headers=None)

Retrieves information about the status of the basic license.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/get-basic-status.html

get_trial_status(params=None, headers=None)

Retrieves information about the status of the trial license.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/get-trial-status.html

post(body=None, params=None, headers=None)

Updates the license for the cluster.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/update-license.html

Parameters
  • body – licenses to be installed

  • acknowledge – whether the user has acknowledged acknowledge messages (default: false)

post_start_basic(params=None, headers=None)

Starts an indefinite basic license.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/start-basic.html

Parameters

acknowledge – whether the user has acknowledged acknowledge messages (default: false)

post_start_trial(params=None, headers=None)

starts a limited time trial license.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/start-trial.html

Parameters
  • acknowledge – whether the user has acknowledged acknowledge messages (default: false)

  • type – The type of trial license to generate (default: “trial”)

Logstash

class elasticsearch.client.LogstashClient(client)
delete_pipeline(id, params=None, headers=None)

Deletes Logstash Pipelines used by Central Management

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/logstash-api-delete-pipeline.html

Parameters

id – The ID of the Pipeline

get_pipeline(id, params=None, headers=None)

Retrieves Logstash Pipelines used by Central Management

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/logstash-api-get-pipeline.html

Parameters

id – A comma-separated list of Pipeline IDs

put_pipeline(id, body, params=None, headers=None)

Adds and updates Logstash Pipelines used for Central Management

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/logstash-api-put-pipeline.html

Parameters
  • id – The ID of the Pipeline

  • body – The Pipeline to add or update

Migration

class elasticsearch.client.MigrationClient(client)
deprecations(index=None, params=None, headers=None)

Retrieves information about different cluster, node, and index level settings that use deprecated features that will be removed or changed in the next major version.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/migration-api-deprecation.html

Parameters

index – Index pattern

get_feature_upgrade_status(params=None, headers=None)

Find out whether system features need to be upgraded or not

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/migration-api-feature-upgrade.html

post_feature_upgrade(params=None, headers=None)

Begin upgrades for system features

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/migration-api-feature-upgrade.html

Machine Learning (ML)

class elasticsearch.client.MlClient(client)
close_job(job_id, body=None, params=None, headers=None)

Closes one or more anomaly detection jobs. A job can be opened and closed multiple times throughout its lifecycle.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-close-job.html

Parameters
  • job_id – The name of the job to close

  • body – The URL params optionally sent in the body

  • allow_no_jobs – Whether to ignore if a wildcard expression matches no jobs. (This includes _all string or when no jobs have been specified)

  • allow_no_match – Whether to ignore if a wildcard expression matches no jobs. (This includes _all string or when no jobs have been specified)

  • force – True if the job should be forcefully closed

  • timeout – Controls the time to wait until a job has closed. Default to 30 minutes

delete_calendar(calendar_id, params=None, headers=None)

Deletes a calendar.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-delete-calendar.html

Parameters

calendar_id – The ID of the calendar to delete

delete_calendar_event(calendar_id, event_id, params=None, headers=None)

Deletes scheduled events from a calendar.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-delete-calendar-event.html

Parameters
  • calendar_id – The ID of the calendar to modify

  • event_id – The ID of the event to remove from the calendar

delete_calendar_job(calendar_id, job_id, params=None, headers=None)

Deletes anomaly detection jobs from a calendar.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-delete-calendar-job.html

Parameters
  • calendar_id – The ID of the calendar to modify

  • job_id – The ID of the job to remove from the calendar

delete_data_frame_analytics(id, params=None, headers=None)

Deletes an existing data frame analytics job.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/delete-dfanalytics.html

Parameters
  • id – The ID of the data frame analytics to delete

  • force – True if the job should be forcefully deleted

  • timeout – Controls the time to wait until a job is deleted. Defaults to 1 minute

delete_datafeed(datafeed_id, params=None, headers=None)

Deletes an existing datafeed.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-delete-datafeed.html

Parameters
  • datafeed_id – The ID of the datafeed to delete

  • force – True if the datafeed should be forcefully deleted

delete_expired_data(body=None, job_id=None, params=None, headers=None)

Deletes expired and unused machine learning data.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-delete-expired-data.html

Parameters
  • body – deleting expired data parameters

  • job_id – The ID of the job(s) to perform expired data hygiene for

  • requests_per_second – The desired requests per second for the deletion processes.

  • timeout – How long can the underlying delete processes run until they are canceled

delete_filter(filter_id, params=None, headers=None)

Deletes a filter.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-delete-filter.html

Parameters

filter_id – The ID of the filter to delete

delete_forecast(job_id, forecast_id=None, params=None, headers=None)

Deletes forecasts from a machine learning job.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-delete-forecast.html

Parameters
  • job_id – The ID of the job from which to delete forecasts

  • forecast_id – The ID of the forecast to delete, can be comma delimited list. Leaving blank implies _all

  • allow_no_forecasts – Whether to ignore if _all matches no forecasts

  • timeout – Controls the time to wait until the forecast(s) are deleted. Default to 30 seconds

delete_job(job_id, params=None, headers=None)

Deletes an existing anomaly detection job.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-delete-job.html

Parameters
  • job_id – The ID of the job to delete

  • force – True if the job should be forcefully deleted

  • wait_for_completion – Should this request wait until the operation has completed before returning Default: True

delete_model_snapshot(job_id, snapshot_id, params=None, headers=None)

Deletes an existing model snapshot.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-delete-snapshot.html

Parameters
  • job_id – The ID of the job to fetch

  • snapshot_id – The ID of the snapshot to delete

delete_trained_model(model_id, params=None, headers=None)

Deletes an existing trained inference model that is currently not referenced by an ingest pipeline.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/delete-trained-models.html

Parameters

model_id – The ID of the trained model to delete

delete_trained_model_alias(model_id, model_alias, params=None, headers=None)

Deletes a model alias that refers to the trained model

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/delete-trained-models-aliases.html

Parameters
  • model_id – The trained model where the model alias is assigned

  • model_alias – The trained model alias to delete

estimate_model_memory(body, params=None, headers=None)

Estimates the model memory

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-apis.html

Parameters

body – The analysis config, plus cardinality estimates for fields it references

evaluate_data_frame(body, params=None, headers=None)

Evaluates the data frame analytics for an annotated index.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/evaluate-dfanalytics.html

Parameters

body – The evaluation definition

explain_data_frame_analytics(body=None, id=None, params=None, headers=None)

Explains a data frame analytics config.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/explain-dfanalytics.html

Parameters
  • body – The data frame analytics config to explain

  • id – The ID of the data frame analytics to explain

find_file_structure(body, params=None, headers=None)

Finds the structure of a text file. The text file must contain data that is suitable to be ingested into Elasticsearch.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/find-structure.html

Warning

This API is experimental so may include breaking changes or be removed in a future version

Parameters
  • body – The contents of the file to be analyzed

  • charset – Optional parameter to specify the character set of the file

  • column_names – Optional parameter containing a comma separated list of the column names for a delimited file

  • delimiter – Optional parameter to specify the delimiter character for a delimited file - must be a single character

  • explain – Whether to include a commentary on how the structure was derived

  • format – Optional parameter to specify the high level file format Valid choices: ndjson, xml, delimited, semi_structured_text

  • grok_pattern – Optional parameter to specify the Grok pattern that should be used to extract fields from messages in a semi- structured text file

  • has_header_row – Optional parameter to specify whether a delimited file includes the column names in its first row

  • line_merge_size_limit – Maximum number of characters permitted in a single message when lines are merged to create messages. Default: 10000

  • lines_to_sample – How many lines of the file should be included in the analysis Default: 1000

  • quote – Optional parameter to specify the quote character for a delimited file - must be a single character

  • should_trim_fields – Optional parameter to specify whether the values between delimiters in a delimited file should have whitespace trimmed from them

  • timeout – Timeout after which the analysis will be aborted Default: 25s

  • timestamp_field – Optional parameter to specify the timestamp field in the file

  • timestamp_format – Optional parameter to specify the timestamp format in the file - may be either a Joda or Java time format

flush_job(job_id, body=None, params=None, headers=None)

Forces any buffered data to be processed by the job.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-flush-job.html

Parameters
  • job_id – The name of the job to flush

  • body – Flush parameters

  • advance_time – Advances time to the given value generating results and updating the model for the advanced interval

  • calc_interim – Calculates interim results for the most recent bucket or all buckets within the latency period

  • end – When used in conjunction with calc_interim, specifies the range of buckets on which to calculate interim results

  • skip_time – Skips time to the given value without generating results or updating the model for the skipped interval

  • start – When used in conjunction with calc_interim, specifies the range of buckets on which to calculate interim results

forecast(job_id, body=None, params=None, headers=None)

Predicts the future behavior of a time series by using its historical behavior.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-forecast.html

Parameters
  • job_id – The ID of the job to forecast for

  • body – Query parameters can be specified in the body

  • duration – The duration of the forecast

  • expires_in – The time interval after which the forecast expires. Expired forecasts will be deleted at the first opportunity.

  • max_model_memory – The max memory able to be used by the forecast. Default is 20mb.

get_buckets(job_id, body=None, timestamp=None, params=None, headers=None)

Retrieves anomaly detection job results for one or more buckets.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-get-bucket.html

Parameters
  • job_id – ID of the job to get bucket results from

  • body – Bucket selection details if not provided in URI

  • timestamp – The timestamp of the desired single bucket result

  • anomaly_score – Filter for the most anomalous buckets

  • desc – Set the sort direction

  • end – End time filter for buckets

  • exclude_interim – Exclude interim results

  • expand – Include anomaly records

  • from – skips a number of buckets

  • size – specifies a max number of buckets to get

  • sort – Sort buckets by a particular field

  • start – Start time filter for buckets

get_calendar_events(calendar_id, params=None, headers=None)

Retrieves information about the scheduled events in calendars.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-get-calendar-event.html

Parameters
  • calendar_id – The ID of the calendar containing the events

  • end – Get events before this time

  • from – Skips a number of events

  • job_id – Get events for the job. When this option is used calendar_id must be ‘_all’

  • size – Specifies a max number of events to get

  • start – Get events after this time

get_calendars(body=None, calendar_id=None, params=None, headers=None)

Retrieves configuration information for calendars.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-get-calendar.html

Parameters
  • body – The from and size parameters optionally sent in the body

  • calendar_id – The ID of the calendar to fetch

  • from – skips a number of calendars

  • size – specifies a max number of calendars to get

get_categories(job_id, body=None, category_id=None, params=None, headers=None)

Retrieves anomaly detection job results for one or more categories.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-get-category.html

Parameters
  • job_id – The name of the job

  • body – Category selection details if not provided in URI

  • category_id – The identifier of the category definition of interest

  • from – skips a number of categories

  • partition_field_value – Specifies the partition to retrieve categories for. This is optional, and should never be used for jobs where per-partition categorization is disabled.

  • size – specifies a max number of categories to get

get_data_frame_analytics(id=None, params=None, headers=None)

Retrieves configuration information for data frame analytics jobs.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/get-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 data frame analytics. (This includes _all string or when no data frame analytics have been specified) Default: True

  • exclude_generated – Omits fields that are illegal to set on data frame analytics PUT

  • from – skips a number of analytics

  • size – specifies a max number of analytics to get Default: 100

get_data_frame_analytics_stats(id=None, params=None, headers=None)

Retrieves usage information for data frame analytics jobs.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/get-dfanalytics-stats.html

Parameters
  • id – The ID of the data frame analytics stats to fetch

  • allow_no_match – Whether to ignore if a wildcard expression matches no data frame analytics. (This includes _all string or when no data frame analytics have been specified) Default: True

  • from – skips a number of analytics

  • size – specifies a max number of analytics to get Default: 100

  • verbose – whether the stats response should be verbose

get_datafeed_stats(datafeed_id=None, params=None, headers=None)

Retrieves usage information for datafeeds.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-get-datafeed-stats.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)

  • allow_no_match – Whether to ignore if a wildcard expression matches no datafeeds. (This includes _all string or when no datafeeds have been specified)

get_datafeeds(datafeed_id=None, params=None, headers=None)

Retrieves configuration information for datafeeds.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-get-datafeed.html

Parameters
  • datafeed_id – The ID of the datafeeds 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)

  • allow_no_match – Whether to ignore if a wildcard expression matches no datafeeds. (This includes _all string or when no datafeeds have been specified)

  • exclude_generated – Omits fields that are illegal to set on datafeed PUT

get_filters(filter_id=None, params=None, headers=None)

Retrieves filters.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-get-filter.html

Parameters
  • filter_id – The ID of the filter to fetch

  • from – skips a number of filters

  • size – specifies a max number of filters to get

get_influencers(job_id, body=None, params=None, headers=None)

Retrieves anomaly detection job results for one or more influencers.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-get-influencer.html

Parameters
  • job_id – Identifier for the anomaly detection job

  • body – Influencer selection criteria

  • desc – whether the results should be sorted in decending order

  • end – end timestamp for the requested influencers

  • exclude_interim – Exclude interim results

  • from – skips a number of influencers

  • influencer_score – influencer score threshold for the requested influencers

  • size – specifies a max number of influencers to get

  • sort – sort field for the requested influencers

  • start – start timestamp for the requested influencers

get_job_stats(job_id=None, params=None, headers=None)

Retrieves usage information for anomaly detection jobs.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-get-job-stats.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)

  • allow_no_match – Whether to ignore if a wildcard expression matches no jobs. (This includes _all string or when no jobs have been specified)

get_jobs(job_id=None, params=None, headers=None)

Retrieves configuration information for anomaly detection jobs.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-get-job.html

Parameters
  • job_id – The ID of the jobs 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)

  • allow_no_match – Whether to ignore if a wildcard expression matches no jobs. (This includes _all string or when no jobs have been specified)

  • exclude_generated – Omits fields that are illegal to set on job PUT

get_model_snapshot_upgrade_stats(job_id, snapshot_id, params=None, headers=None)

Gets stats for anomaly detection job model snapshot upgrades that are in progress.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-get-job-model-snapshot-upgrade-stats.html

Parameters
  • job_id – The ID of the job. May be a wildcard, comma separated list or _all.

  • snapshot_id – The ID of the snapshot. May be a wildcard, comma separated list or _all.

  • allow_no_match – Whether to ignore if a wildcard expression matches no jobs or no snapshots. (This includes the _all string.)

get_model_snapshots(job_id, body=None, snapshot_id=None, params=None, headers=None)

Retrieves information about model snapshots.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-get-snapshot.html

Parameters
  • job_id – The ID of the job to fetch

  • body – Model snapshot selection criteria

  • snapshot_id – The ID of the snapshot to fetch

  • desc – True if the results should be sorted in descending order

  • end – The filter ‘end’ query parameter

  • from – Skips a number of documents

  • size – The default number of documents returned in queries as a string.

  • sort – Name of the field to sort on

  • start – The filter ‘start’ query parameter

get_overall_buckets(job_id, body=None, params=None, headers=None)

Retrieves overall bucket results that summarize the bucket results of multiple anomaly detection jobs.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-get-overall-buckets.html

Parameters
  • job_id – The job IDs for which to calculate overall bucket results

  • body – Overall bucket selection details if not provided in URI

  • allow_no_jobs – Whether to ignore if a wildcard expression matches no jobs. (This includes _all string or when no jobs have been specified)

  • allow_no_match – Whether to ignore if a wildcard expression matches no jobs. (This includes _all string or when no jobs have been specified)

  • bucket_span – The span of the overall buckets. Defaults to the longest job bucket_span

  • end – Returns overall buckets with timestamps earlier than this time

  • exclude_interim – If true overall buckets that include interim buckets will be excluded

  • overall_score – Returns overall buckets with overall scores higher than this value

  • start – Returns overall buckets with timestamps after this time

  • top_n – The number of top job bucket scores to be used in the overall_score calculation

get_records(job_id, body=None, params=None, headers=None)

Retrieves anomaly records for an anomaly detection job.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-get-record.html

Parameters
  • job_id – The ID of the job

  • body – Record selection criteria

  • desc – Set the sort direction

  • end – End time filter for records

  • exclude_interim – Exclude interim results

  • from – skips a number of records

  • record_score – Returns records with anomaly scores greater or equal than this value

  • size – specifies a max number of records to get

  • sort – Sort records by a particular field

  • start – Start time filter for records

get_trained_models(model_id=None, params=None, headers=None)

Retrieves configuration information for a trained inference model.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/get-trained-models.html

Parameters
  • model_id – The ID of the trained models 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

  • decompress_definition – Should the model definition be decompressed into valid JSON or returned in a custom compressed format. Defaults to true. Default: True

  • exclude_generated – Omits fields that are illegal to set on model PUT

  • from – skips a number of trained models

  • include – A comma-separate list of fields to optionally include. Valid options are ‘definition’ and ‘total_feature_importance’. Default is none.

  • include_model_definition – Should the full model definition be included in the results. These definitions can be large. So be cautious when including them. Defaults to false.

  • size – specifies a max number of trained models to get Default: 100

  • tags – A comma-separated list of tags that the model must have.

get_trained_models_stats(model_id=None, params=None, headers=None)

Retrieves usage information for trained inference models.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/get-trained-models-stats.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

  • from – skips a number of trained models

  • size – specifies a max number of trained models to get Default: 100

info(params=None, headers=None)

Returns defaults and limits used by machine learning.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/get-ml-info.html

open_job(job_id, body=None, params=None, headers=None)

Opens one or more anomaly detection jobs.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-open-job.html

Parameters
  • job_id – The ID of the job to open

  • body – Query parameters can be specified in the body

post_calendar_events(calendar_id, body, params=None, headers=None)

Posts scheduled events in a calendar.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-post-calendar-event.html

Parameters
  • calendar_id – The ID of the calendar to modify

  • body – A list of events

post_data(job_id, body, params=None, headers=None)

Sends data to an anomaly detection job for analysis.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-post-data.html

Parameters
  • job_id – The name of the job receiving the data

  • body – The data to process

  • reset_end – Optional parameter to specify the end of the bucket resetting range

  • reset_start – Optional parameter to specify the start of the bucket resetting range

preview_data_frame_analytics(body=None, id=None, params=None, headers=None)

Previews that will be analyzed given a data frame analytics config.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/preview-dfanalytics.html

Parameters
  • body – The data frame analytics config to preview

  • id – The ID of the data frame analytics to preview

preview_datafeed(body=None, datafeed_id=None, params=None, headers=None)

Previews a datafeed.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-preview-datafeed.html

Parameters
  • body – The datafeed config and job config with which to execute the preview

  • datafeed_id – The ID of the datafeed to preview

put_calendar(calendar_id, body=None, params=None, headers=None)

Instantiates a calendar.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-put-calendar.html

Parameters
  • calendar_id – The ID of the calendar to create

  • body – The calendar details

put_calendar_job(calendar_id, job_id, params=None, headers=None)

Adds an anomaly detection job to a calendar.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-put-calendar-job.html

Parameters
  • calendar_id – The ID of the calendar to modify

  • job_id – The ID of the job to add to the calendar

put_data_frame_analytics(id, body, params=None, headers=None)

Instantiates a data frame analytics job.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/put-dfanalytics.html

Parameters
  • id – The ID of the data frame analytics to create

  • body – The data frame analytics configuration

put_datafeed(datafeed_id, body, params=None, headers=None)

Instantiates a datafeed.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-put-datafeed.html

Parameters
  • datafeed_id – The ID of the datafeed to create

  • body – The datafeed config

  • allow_no_indices – Ignore if the source indices expressions resolves to no concrete indices (default: true)

  • expand_wildcards – Whether source index expressions should get expanded to open or closed indices (default: open) Valid choices: open, closed, hidden, none, all

  • ignore_throttled – Ignore indices that are marked as throttled (default: true)

  • ignore_unavailable – Ignore unavailable indexes (default: false)

put_filter(filter_id, body, params=None, headers=None)

Instantiates a filter.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-put-filter.html

Parameters
  • filter_id – The ID of the filter to create

  • body – The filter details

put_job(job_id, body, params=None, headers=None)

Instantiates an anomaly detection job.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-put-job.html

Parameters
  • job_id – The ID of the job to create

  • body – The job

  • allow_no_indices – Ignore if the source indices expressions resolves to no concrete indices (default: true). Only set if datafeed_config is provided.

  • expand_wildcards – Whether source index expressions should get expanded to open or closed indices (default: open). Only set if datafeed_config is provided. Valid choices: open, closed, hidden, none, all

  • ignore_throttled – Ignore indices that are marked as throttled (default: true). Only set if datafeed_config is provided.

  • ignore_unavailable – Ignore unavailable indexes (default: false). Only set if datafeed_config is provided.

put_trained_model(model_id, body, params=None, headers=None)

Creates an inference trained model.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/put-trained-models.html

Parameters
  • model_id – The ID of the trained models to store

  • body – The trained model configuration

  • defer_definition_decompression – If set to true and a compressed_definition is provided, the request defers definition decompression and skips relevant validations.

put_trained_model_alias(model_id, model_alias, params=None, headers=None)

Creates a new model alias (or reassigns an existing one) to refer to the trained model

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/put-trained-models-aliases.html

Parameters
  • model_id – The trained model where the model alias should be assigned

  • model_alias – The trained model alias to update

  • reassign – If the model_alias already exists and points to a separate model_id, this parameter must be true. Defaults to false.

reset_job(job_id, params=None, headers=None)

Resets an existing anomaly detection job.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-reset-job.html

Parameters
  • job_id – The ID of the job to reset

  • wait_for_completion – Should this request wait until the operation has completed before returning Default: True

revert_model_snapshot(job_id, snapshot_id, body=None, params=None, headers=None)

Reverts to a specific snapshot.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-revert-snapshot.html

Parameters
  • job_id – The ID of the job to fetch

  • snapshot_id – The ID of the snapshot to revert to

  • body – Reversion options

  • delete_intervening_results – Should we reset the results back to the time of the snapshot?

set_upgrade_mode(params=None, headers=None)

Sets a cluster wide upgrade_mode setting that prepares machine learning indices for an upgrade.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-set-upgrade-mode.html

Parameters
  • enabled – Whether to enable upgrade_mode ML setting or not. Defaults to false.

  • timeout – Controls the time to wait before action times out. Defaults to 30 seconds

start_data_frame_analytics(id, body=None, params=None, headers=None)

Starts a data frame analytics job.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/start-dfanalytics.html

Parameters
  • id – The ID of the data frame analytics to start

  • body – The start data frame analytics parameters

  • timeout – Controls the time to wait until the task has started. Defaults to 20 seconds

start_datafeed(datafeed_id, body=None, params=None, headers=None)

Starts one or more datafeeds.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-start-datafeed.html

Parameters
  • datafeed_id – The ID of the datafeed to start

  • body – The start datafeed parameters

  • end – The end time when the datafeed should stop. When not set, the datafeed continues in real time

  • start – The start time from where the datafeed should begin

  • timeout – Controls the time to wait until a datafeed has started. Default to 20 seconds

stop_data_frame_analytics(id, body=None, params=None, headers=None)

Stops one or more data frame analytics jobs.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/stop-dfanalytics.html

Parameters
  • id – The ID of the data frame analytics to stop

  • body – The stop data frame analytics parameters

  • allow_no_match – Whether to ignore if a wildcard expression matches no data frame analytics. (This includes _all string or when no data frame analytics have been specified)

  • force – True if the data frame analytics should be forcefully stopped

  • timeout – Controls the time to wait until the task has stopped. Defaults to 20 seconds

stop_datafeed(datafeed_id, body=None, params=None, headers=None)

Stops one or more datafeeds.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-stop-datafeed.html

Parameters
  • datafeed_id – The ID of the datafeed to stop

  • body – The URL params optionally sent in the body

  • allow_no_datafeeds – Whether to ignore if a wildcard expression matches no datafeeds. (This includes _all string or when no datafeeds have been specified)

  • allow_no_match – Whether to ignore if a wildcard expression matches no datafeeds. (This includes _all string or when no datafeeds have been specified)

  • force – True if the datafeed should be forcefully stopped.

  • timeout – Controls the time to wait until a datafeed has stopped. Default to 20 seconds

update_data_frame_analytics(id, body, params=None, headers=None)

Updates certain properties of a data frame analytics job.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/update-dfanalytics.html

Parameters
  • id – The ID of the data frame analytics to update

  • body – The data frame analytics settings to update

update_datafeed(datafeed_id, body, params=None, headers=None)

Updates certain properties of a datafeed.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-update-datafeed.html

Parameters
  • datafeed_id – The ID of the datafeed to update

  • body – The datafeed update settings

  • allow_no_indices – Ignore if the source indices expressions resolves to no concrete indices (default: true)

  • expand_wildcards – Whether source index expressions should get expanded to open or closed indices (default: open) Valid choices: open, closed, hidden, none, all

  • ignore_throttled – Ignore indices that are marked as throttled (default: true)

  • ignore_unavailable – Ignore unavailable indexes (default: false)

update_filter(filter_id, body, params=None, headers=None)

Updates the description of a filter, adds items, or removes items.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-update-filter.html

Parameters
  • filter_id – The ID of the filter to update

  • body – The filter update

update_job(job_id, body, params=None, headers=None)

Updates certain properties of an anomaly detection job.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-update-job.html

Parameters
  • job_id – The ID of the job to create

  • body – The job update settings

update_model_snapshot(job_id, snapshot_id, body, params=None, headers=None)

Updates certain properties of a snapshot.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-update-snapshot.html

Parameters
  • job_id – The ID of the job to fetch

  • snapshot_id – The ID of the snapshot to update

  • body – The model snapshot properties to update

upgrade_job_snapshot(job_id, snapshot_id, params=None, headers=None)

Upgrades a given job snapshot to the current major version.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/ml-upgrade-job-model-snapshot.html

Parameters
  • job_id – The ID of the job

  • snapshot_id – The ID of the snapshot

  • timeout – How long should the API wait for the job to be opened and the old snapshot to be loaded.

  • wait_for_completion – Should the request wait until the task is complete before responding to the caller. Default is false.

validate(body, params=None, headers=None)

Validates an anomaly detection job.

https://www.elastic.co/guide/en/machine-learning/current/ml-jobs.html

Parameters

body – The job config

validate_detector(body, params=None, headers=None)

Validates an anomaly detection detector.

https://www.elastic.co/guide/en/machine-learning/current/ml-jobs.html

Parameters

body – The detector

Monitoring

class elasticsearch.client.MonitoringClient(client)
bulk(body, doc_type=None, params=None, headers=None)

Used by the monitoring features to send monitoring data.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/monitor-elasticsearch-cluster.html

Parameters
  • body – The operation definition and data (action-data pairs), separated by newlines

  • doc_type – Default document type for items which don’t provide one

  • interval – Collection interval (e.g., ’10s’ or ‘10000ms’) of the payload

  • system_api_version – API Version of the monitored system

  • system_id – Identifier of the monitored system

Nodes

class elasticsearch.client.NodesClient(client)
clear_repositories_metering_archive(node_id, max_archive_version, params=None, headers=None)

Removes the archived repositories metering information present in the cluster.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/clear-repositories-metering-archive-api.html

Warning

This API is experimental so may include breaking changes or be removed in a future version

Parameters
  • node_id – Comma-separated list of node IDs or names used to limit returned information.

  • max_archive_version – Specifies the maximum archive_version to be cleared from the archive.

get_repositories_metering_info(node_id, params=None, headers=None)

Returns cluster repositories metering information.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/get-repositories-metering-api.html

Warning

This API is experimental so may include breaking changes or be removed in a future version

Parameters

node_id – A comma-separated list of node IDs or names to limit the returned information.

hot_threads(node_id=None, params=None, headers=None)

Returns information about hot threads on each node in the cluster.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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

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

  • sort – The sort order for ‘cpu’ type (default: total) Valid choices: cpu, total

  • threads – Specify the number of threads to provide information for (default: 3)

  • timeout – Explicit operation timeout

  • type – The type to sample (default: cpu) Valid choices: cpu, wait, block, mem

info(node_id=None, metric=None, params=None, headers=None)

Returns information about nodes in the cluster.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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. Use _all to retrieve all metrics and _none to retrieve the node identity without any additional metrics. Valid choices: settings, os, process, jvm, thread_pool, transport, http, plugins, ingest, indices, aggregations, _all, _none

  • flat_settings – Return settings in flat format (default: false)

  • timeout – Explicit operation timeout

reload_secure_settings(body=None, node_id=None, params=None, headers=None)

Reloads secure settings.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(node_id=None, metric=None, index_metric=None, params=None, headers=None)

Returns statistical information about nodes in the cluster.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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, indexing_pressure

  • 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, shard_stats

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

  • include_unloaded_segments – If set to true segment stats will include stats for segments that are not currently loaded into memory

  • 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(node_id=None, metric=None, params=None, headers=None)

Returns low-level information about REST actions usage on nodes.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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

Rollup Indices

class elasticsearch.client.RollupClient(client)
delete_job(id, params=None, headers=None)

Deletes an existing rollup job.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/rollup-delete-job.html

Warning

This API is experimental so may include breaking changes or be removed in a future version

Parameters

id – The ID of the job to delete

get_jobs(id=None, params=None, headers=None)

Retrieves the configuration, stats, and status of rollup jobs.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/rollup-get-job.html

Warning

This API is experimental so may include breaking changes or be removed in a future version

Parameters

id – The ID of the job(s) to fetch. Accepts glob patterns, or left blank for all jobs

get_rollup_caps(id=None, params=None, headers=None)

Returns the capabilities of any rollup jobs that have been configured for a specific index or index pattern.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/rollup-get-rollup-caps.html

Warning

This API is experimental so may include breaking changes or be removed in a future version

Parameters

id – The ID of the index to check rollup capabilities on, or left blank for all jobs

get_rollup_index_caps(index, params=None, headers=None)

Returns the rollup capabilities of all jobs inside of a rollup index (e.g. the index where rollup data is stored).

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/rollup-get-rollup-index-caps.html

Warning

This API is experimental so may include breaking changes or be removed in a future version

Parameters

index – The rollup index or index pattern to obtain rollup capabilities from.

put_job(id, body, params=None, headers=None)

Creates a rollup job.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/rollup-put-job.html

Warning

This API is experimental so may include breaking changes or be removed in a future version

Parameters
  • id – The ID of the job to create

  • body – The job configuration

rollup(index, rollup_index, body, params=None, headers=None)

Rollup an index

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/xpack-rollup.html

Warning

This API is experimental so may include breaking changes or be removed in a future version

Parameters
  • index – The index to roll up

  • rollup_index – The name of the rollup index to create

  • body – The rollup configuration

Enables searching rolled-up data using the standard query DSL.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/rollup-search.html

Warning

This API is experimental so may include breaking changes or be removed in a future version

Parameters
  • index – The indices or index-pattern(s) (containing rollup or regular data) that should be searched

  • body – The search request body

  • doc_type – The doc type inside the index

  • rest_total_hits_as_int – Indicates whether hits.total should be rendered as an integer or an object in the rest search response

  • typed_keys – Specify whether aggregation and suggester names should be prefixed by their respective types in the response

start_job(id, params=None, headers=None)

Starts an existing, stopped rollup job.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/rollup-start-job.html

Warning

This API is experimental so may include breaking changes or be removed in a future version

Parameters

id – The ID of the job to start

stop_job(id, params=None, headers=None)

Stops an existing, started rollup job.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/rollup-stop-job.html

Warning

This API is experimental so may include breaking changes or be removed in a future version

Parameters
  • id – The ID of the job to stop

  • timeout – Block for (at maximum) the specified duration while waiting for the job to stop. Defaults to 30s.

  • wait_for_completion – True if the API should block until the job has fully stopped, false if should be executed async. Defaults to false.

Searchable Snapshots

class elasticsearch.client.SearchableSnapshotsClient(client)
cache_stats(node_id=None, params=None, headers=None)

Retrieve node-level cache statistics about searchable snapshots.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/searchable-snapshots-apis.html

Warning

This API is experimental so may include breaking changes or be removed in a future version

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

clear_cache(index=None, params=None, headers=None)

Clear the cache of searchable snapshots.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/searchable-snapshots-apis.html

Warning

This API is experimental so may include breaking changes or be removed in a future version

Parameters
  • index – A comma-separated list of index names

  • allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)

  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both. Valid choices: open, closed, none, all Default: open

  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)

mount(repository, snapshot, body, params=None, headers=None)

Mount a snapshot as a searchable index.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/searchable-snapshots-api-mount-snapshot.html

Parameters
  • repository – The name of the repository containing the snapshot of the index to mount

  • snapshot – The name of the snapshot of the index to mount

  • body – The restore configuration for mounting the snapshot as searchable

  • master_timeout – Explicit operation timeout for connection to master node

  • storage – Selects the kind of local storage used to accelerate searches. Experimental, and defaults to full_copy

  • wait_for_completion – Should this request wait until the operation has completed before returning

repository_stats(repository, params=None, headers=None)

DEPRECATED: This API is replaced by the Repositories Metering API.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/searchable-snapshots-apis.html

Warning

This API is experimental so may include breaking changes or be removed in a future version

Parameters

repository – The repository for which to get the stats for

stats(index=None, params=None, headers=None)

Retrieve shard-level statistics about searchable snapshots.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/searchable-snapshots-apis.html

Parameters
  • index – A comma-separated list of index names

  • level – Return stats aggregated at cluster, index or shard level Valid choices: cluster, indices, shards Default: indices

Security

class elasticsearch.client.SecurityClient(client)
authenticate(params=None, headers=None)

Enables authentication as a user and retrieve information about the authenticated user.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-authenticate.html

change_password(body, username=None, params=None, headers=None)

Changes the passwords of users in the native realm and built-in users.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-change-password.html

Parameters
  • body – the new password for the user

  • username – The username of the user to change the password for

  • refresh – If true (the default) 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 then do nothing with refreshes. Valid choices: true, false, wait_for

clear_api_key_cache(ids, params=None, headers=None)

Clear a subset or all entries from the API key cache.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-clear-api-key-cache.html

Parameters

ids – A comma-separated list of IDs of API keys to clear from the cache

clear_cached_privileges(application, params=None, headers=None)

Evicts application privileges from the native application privileges cache.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-clear-privilege-cache.html

Parameters

application – A comma-separated list of application names

clear_cached_realms(realms, params=None, headers=None)

Evicts users from the user cache. Can completely clear the cache or evict specific users.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-clear-cache.html

Parameters
  • realms – Comma-separated list of realms to clear

  • usernames – Comma-separated list of usernames to clear from the cache

clear_cached_roles(name, params=None, headers=None)

Evicts roles from the native role cache.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-clear-role-cache.html

Parameters

name – Role name

clear_cached_service_tokens(namespace, service, name, params=None, headers=None)

Evicts tokens from the service account token caches.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-clear-service-token-caches.html

Parameters
  • namespace – An identifier for the namespace

  • service – An identifier for the service name

  • name – A comma-separated list of service token names

create_api_key(body, params=None, headers=None)

Creates an API key for access without requiring basic authentication.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-create-api-key.html

Parameters
  • body – The api key request to create an API key

  • refresh – If true (the default) 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 then do nothing with refreshes. Valid choices: true, false, wait_for

create_service_token(namespace, service, name=None, params=None, headers=None)

Creates a service account token for access without requiring basic authentication.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-create-service-token.html

Parameters
  • namespace – An identifier for the namespace

  • service – An identifier for the service name

  • name – An identifier for the token name

  • refresh – If true then refresh the affected shards to make this operation visible to search, if wait_for (the default) then wait for a refresh to make this operation visible to search, if false then do nothing with refreshes. Valid choices: true, false, wait_for

delete_privileges(application, name, params=None, headers=None)

Removes application privileges.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-delete-privilege.html

Parameters
  • application – Application name

  • name – Privilege name

  • refresh – If true (the default) 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 then do nothing with refreshes. Valid choices: true, false, wait_for

delete_role(name, params=None, headers=None)

Removes roles in the native realm.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-delete-role.html

Parameters
  • name – Role name

  • refresh – If true (the default) 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 then do nothing with refreshes. Valid choices: true, false, wait_for

delete_role_mapping(name, params=None, headers=None)

Removes role mappings.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-delete-role-mapping.html

Parameters
  • name – Role-mapping name

  • refresh – If true (the default) 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 then do nothing with refreshes. Valid choices: true, false, wait_for

delete_service_token(namespace, service, name, params=None, headers=None)

Deletes a service account token.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-delete-service-token.html

Parameters
  • namespace – An identifier for the namespace

  • service – An identifier for the service name

  • name – An identifier for the token name

  • refresh – If true then refresh the affected shards to make this operation visible to search, if wait_for (the default) then wait for a refresh to make this operation visible to search, if false then do nothing with refreshes. Valid choices: true, false, wait_for

delete_user(username, params=None, headers=None)

Deletes users from the native realm.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-delete-user.html

Parameters
  • username – username

  • refresh – If true (the default) 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 then do nothing with refreshes. Valid choices: true, false, wait_for

disable_user(username, params=None, headers=None)

Disables users in the native realm.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-disable-user.html

Parameters
  • username – The username of the user to disable

  • refresh – If true (the default) 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 then do nothing with refreshes. Valid choices: true, false, wait_for

enable_user(username, params=None, headers=None)

Enables users in the native realm.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-enable-user.html

Parameters
  • username – The username of the user to enable

  • refresh – If true (the default) 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 then do nothing with refreshes. Valid choices: true, false, wait_for

get_api_key(params=None, headers=None)

Retrieves information for one or more API keys.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-get-api-key.html

Parameters
  • id – API key id of the API key to be retrieved

  • name – API key name of the API key to be retrieved

  • owner – flag to query API keys owned by the currently authenticated user

  • realm_name – realm name of the user who created this API key to be retrieved

  • username – user name of the user who created this API key to be retrieved

get_builtin_privileges(params=None, headers=None)

Retrieves the list of cluster privileges and index privileges that are available in this version of Elasticsearch.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-get-builtin-privileges.html

get_privileges(application=None, name=None, params=None, headers=None)

Retrieves application privileges.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-get-privileges.html

Parameters
  • application – Application name

  • name – Privilege name

get_role(name=None, params=None, headers=None)

Retrieves roles in the native realm.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-get-role.html

Parameters

name – A comma-separated list of role names

get_role_mapping(name=None, params=None, headers=None)

Retrieves role mappings.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-get-role-mapping.html

Parameters

name – A comma-separated list of role-mapping names

get_service_accounts(namespace=None, service=None, params=None, headers=None)

Retrieves information about service accounts.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-get-service-accounts.html

Parameters
  • namespace – An identifier for the namespace

  • service – An identifier for the service name

get_service_credentials(namespace, service, params=None, headers=None)

Retrieves information of all service credentials for a service account.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-get-service-credentials.html

Parameters
  • namespace – An identifier for the namespace

  • service – An identifier for the service name

get_token(body, params=None, headers=None)

Creates a bearer token for access without requiring basic authentication.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-get-token.html

Parameters

body – The token request to get

get_user(username=None, params=None, headers=None)

Retrieves information about users in the native realm and built-in users.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-get-user.html

Parameters

username – A comma-separated list of usernames

get_user_privileges(params=None, headers=None)

Retrieves security privileges for the logged in user.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-get-user-privileges.html

grant_api_key(body, params=None, headers=None)

Creates an API key on behalf of another user.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-grant-api-key.html

Parameters
  • body – The api key request to create an API key

  • refresh – If true (the default) 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 then do nothing with refreshes. Valid choices: true, false, wait_for

has_privileges(body, user=None, params=None, headers=None)

Determines whether the specified user has a specified list of privileges.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-has-privileges.html

Parameters
  • body – The privileges to test

  • user – Username

invalidate_api_key(body, params=None, headers=None)

Invalidates one or more API keys.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-invalidate-api-key.html

Parameters

body – The api key request to invalidate API key(s)

invalidate_token(body, params=None, headers=None)

Invalidates one or more access tokens or refresh tokens.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-invalidate-token.html

Parameters

body – The token to invalidate

put_privileges(body, params=None, headers=None)

Adds or updates application privileges.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-put-privileges.html

Parameters
  • body – The privilege(s) to add

  • refresh – If true (the default) 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 then do nothing with refreshes. Valid choices: true, false, wait_for

put_role(name, body, params=None, headers=None)

Adds and updates roles in the native realm.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-put-role.html

Parameters
  • name – Role name

  • body – The role to add

  • refresh – If true (the default) 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 then do nothing with refreshes. Valid choices: true, false, wait_for

put_role_mapping(name, body, params=None, headers=None)

Creates and updates role mappings.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-put-role-mapping.html

Parameters
  • name – Role-mapping name

  • body – The role mapping to add

  • refresh – If true (the default) 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 then do nothing with refreshes. Valid choices: true, false, wait_for

put_user(username, body, params=None, headers=None)

Adds and updates users in the native realm. These users are commonly referred to as native users.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-put-user.html

Parameters
  • username – The username of the User

  • body – The user to add

  • refresh – If true (the default) 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 then do nothing with refreshes. Valid choices: true, false, wait_for

query_api_keys(body=None, params=None, headers=None)

Retrieves information for API keys using a subset of query DSL

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-query-api-key.html

Parameters

body – From, size, query, sort and search_after

saml_authenticate(body, params=None, headers=None)

Exchanges a SAML Response message for an Elasticsearch access token and refresh token pair

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-saml-authenticate.html

Parameters

body – The SAML response to authenticate

saml_complete_logout(body, params=None, headers=None)

Verifies the logout response sent from the SAML IdP

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-saml-complete-logout.html

Parameters

body – The logout response to verify

saml_invalidate(body, params=None, headers=None)

Consumes a SAML LogoutRequest

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-saml-invalidate.html

Parameters

body – The LogoutRequest message

saml_logout(body, params=None, headers=None)

Invalidates an access token and a refresh token that were generated via the SAML Authenticate API

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-saml-logout.html

Parameters

body – The tokens to invalidate

saml_prepare_authentication(body, params=None, headers=None)

Creates a SAML authentication request

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-saml-prepare-authentication.html

Parameters

body – The realm for which to create the authentication request, identified by either its name or the ACS URL

saml_service_provider_metadata(realm_name, params=None, headers=None)

Generates SAML metadata for the Elastic stack SAML 2.0 Service Provider

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-saml-sp-metadata.html

Parameters

realm_name – The name of the SAML realm to get the metadata for

Shutdown

class elasticsearch.client.ShutdownClient(client)
delete_node(node_id, params=None, headers=None)

Removes a node from the shutdown list. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.

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

Parameters

node_id – The node id of node to be removed from the shutdown state

get_node(node_id=None, params=None, headers=None)

Retrieve status of a node or nodes that are currently marked as shutting down. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.

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

Parameters

node_id – Which node for which to retrieve the shutdown status

put_node(node_id, body, params=None, headers=None)

Adds a node to be shut down. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.

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

Parameters
  • node_id – The node id of node to be shut down

  • body – The shutdown type definition to register

Snapshot Lifecycle Management (SLM)

class elasticsearch.client.SlmClient(client)
delete_lifecycle(policy_id, params=None, headers=None)

Deletes an existing snapshot lifecycle policy.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/slm-api-delete-policy.html

Parameters

policy_id – The id of the snapshot lifecycle policy to remove

execute_lifecycle(policy_id, params=None, headers=None)

Immediately creates a snapshot according to the lifecycle policy, without waiting for the scheduled time.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/slm-api-execute-lifecycle.html

Parameters

policy_id – The id of the snapshot lifecycle policy to be executed

execute_retention(params=None, headers=None)

Deletes any snapshots that are expired according to the policy’s retention rules.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/slm-api-execute-retention.html

get_lifecycle(policy_id=None, params=None, headers=None)

Retrieves one or more snapshot lifecycle policy definitions and information about the latest snapshot attempts.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/slm-api-get-policy.html

Parameters

policy_id – Comma-separated list of snapshot lifecycle policies to retrieve

get_stats(params=None, headers=None)

Returns global and policy-level statistics about actions taken by snapshot lifecycle management.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/slm-api-get-stats.html

get_status(params=None, headers=None)

Retrieves the status of snapshot lifecycle management (SLM).

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/slm-api-get-status.html

put_lifecycle(policy_id, body=None, params=None, headers=None)

Creates or updates a snapshot lifecycle policy.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/slm-api-put-policy.html

Parameters
  • policy_id – The id of the snapshot lifecycle policy

  • body – The snapshot lifecycle policy definition to register

start(params=None, headers=None)

Turns on snapshot lifecycle management (SLM).

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/slm-api-start.html

stop(params=None, headers=None)

Turns off snapshot lifecycle management (SLM).

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/slm-api-stop.html

Snapshots

class elasticsearch.client.SnapshotClient(client)
cleanup_repository(repository, params=None, headers=None)

Removes stale data from repository.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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

clone(repository, snapshot, target_snapshot, body, params=None, headers=None)

Clones indices from one snapshot into another snapshot in the same repository.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/modules-snapshots.html

Parameters
  • repository – A repository name

  • snapshot – The name of the snapshot to clone from

  • target_snapshot – The name of the cloned snapshot to create

  • body – The snapshot clone definition

  • master_timeout – Explicit operation timeout for connection to master node

create(repository, snapshot, body=None, params=None, headers=None)

Creates a snapshot in a repository.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(repository, body, params=None, headers=None)

Creates a repository.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(repository, snapshot, params=None, headers=None)

Deletes a snapshot.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/modules-snapshots.html

Parameters
  • repository – A repository name

  • snapshot – A snapshot name

  • master_timeout – Explicit operation timeout for connection to master node

delete_repository(repository, params=None, headers=None)

Deletes a repository.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/modules-snapshots.html

Parameters
  • repository – Name of the snapshot repository to unregister. Wildcard (*) patterns are supported.

  • master_timeout – Explicit operation timeout for connection to master node

  • timeout – Explicit operation timeout

get(repository, snapshot, params=None, headers=None)

Returns information about a snapshot.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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

  • include_repository – Whether to include the repository name in the snapshot info. Defaults to true.

  • index_details – Whether to include details of each index in the snapshot, if those details are available. Defaults to false.

  • 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(repository=None, params=None, headers=None)

Returns information about a repository.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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

repository_analyze(repository, params=None, headers=None)

Analyzes a repository for correctness and performance

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/modules-snapshots.html

Parameters
  • repository – A repository name

  • blob_count – Number of blobs to create during the test. Defaults to 100.

  • concurrency – Number of operations to run concurrently during the test. Defaults to 10.

  • detailed – Whether to return detailed results or a summary. Defaults to ‘false’ so that only the summary is returned.

  • early_read_node_count – Number of nodes on which to perform an early read on a blob, i.e. before writing has completed. Early reads are rare actions so the ‘rare_action_probability’ parameter is also relevant. Defaults to 2.

  • max_blob_size – Maximum size of a blob to create during the test, e.g ‘1gb’ or ‘100mb’. Defaults to ‘10mb’.

  • max_total_data_size – Maximum total size of all blobs to create during the test, e.g ‘1tb’ or ‘100gb’. Defaults to ‘1gb’.

  • rare_action_probability – Probability of taking a rare action such as an early read or an overwrite. Defaults to 0.02.

  • rarely_abort_writes – Whether to rarely abort writes before they complete. Defaults to ‘true’.

  • read_node_count – Number of nodes on which to read a blob after writing. Defaults to 10.

  • seed – Seed for the random number generator used to create the test workload. Defaults to a random value.

  • timeout – Explicit operation timeout. Defaults to ’30s’.

restore(repository, snapshot, body=None, params=None, headers=None)

Restores a snapshot.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(repository=None, snapshot=None, params=None, headers=None)

Returns information about the status of a snapshot.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/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(repository, params=None, headers=None)

Verifies a repository.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/modules-snapshots.html

Parameters
  • repository – A repository name

  • master_timeout – Explicit operation timeout for connection to master node

  • timeout – Explicit operation timeout

SQL

class elasticsearch.client.SqlClient(client)
clear_cursor(body, params=None, headers=None)

Clears the SQL cursor

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/clear-sql-cursor-api.html

Parameters

body – Specify the cursor value in the cursor element to clean the cursor.

delete_async(id, params=None, headers=None)

Deletes an async SQL search or a stored synchronous SQL search. If the search is still running, the API cancels it.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/delete-async-sql-search-api.html

Parameters

id – The async search ID

get_async(id, params=None, headers=None)

Returns the current status and available results for an async SQL search or stored synchronous SQL search

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/get-async-sql-search-api.html

Parameters
  • id – The async search ID

  • delimiter – Separator for CSV results Default: ,

  • format – Short version of the Accept header, e.g. json, yaml

  • keep_alive – Retention period for the search and its results Default: 5d

  • wait_for_completion_timeout – Duration to wait for complete results

get_async_status(id, params=None, headers=None)

Returns the current status of an async SQL search or a stored synchronous SQL search

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/get-async-sql-search-status-api.html

Parameters

id – The async search ID

query(body, params=None, headers=None)

Executes a SQL request

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/sql-search-api.html

Parameters
  • body – Use the query element to start a query. Use the cursor element to continue a query.

  • format – a short version of the Accept header, e.g. json, yaml

translate(body, params=None, headers=None)

Translates SQL into Elasticsearch queries

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/sql-translate-api.html

Parameters

body – Specify the query in the query element.

TLS/SSL

class elasticsearch.client.SslClient(client)
certificates(params=None, headers=None)

Retrieves information about the X.509 certificates used to encrypt communications in the cluster.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-api-ssl.html

Tasks

class elasticsearch.client.TasksClient(client)
cancel(task_id=None, params=None, headers=None)

Cancels a task, if it can be cancelled through an API.

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

Warning

This API is experimental so may include breaking changes or be removed in a future version

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.

  • wait_for_completion – Should the request block until the cancellation of the task and its descendant tasks is completed. Defaults to false

get(task_id=None, params=None, headers=None)

Returns information about a task.

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

Warning

This API is experimental so may include breaking changes or be removed in a future version

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(params=None, headers=None)

Returns a list of tasks.

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

Warning

This API is experimental so may include breaking changes or be removed in a future version

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)

Text Structure

class elasticsearch.client.TextStructureClient(client)
find_structure(body, params=None, headers=None)

Finds the structure of a text file. The text file must contain data that is suitable to be ingested into Elasticsearch.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/find-structure.html

Parameters
  • body – The contents of the file to be analyzed

  • charset – Optional parameter to specify the character set of the file

  • column_names – Optional parameter containing a comma separated list of the column names for a delimited file

  • delimiter – Optional parameter to specify the delimiter character for a delimited file - must be a single character

  • explain – Whether to include a commentary on how the structure was derived

  • format – Optional parameter to specify the high level file format Valid choices: ndjson, xml, delimited, semi_structured_text

  • grok_pattern – Optional parameter to specify the Grok pattern that should be used to extract fields from messages in a semi- structured text file

  • has_header_row – Optional parameter to specify whether a delimited file includes the column names in its first row

  • line_merge_size_limit – Maximum number of characters permitted in a single message when lines are merged to create messages. Default: 10000

  • lines_to_sample – How many lines of the file should be included in the analysis Default: 1000

  • quote – Optional parameter to specify the quote character for a delimited file - must be a single character

  • should_trim_fields – Optional parameter to specify whether the values between delimiters in a delimited file should have whitespace trimmed from them

  • timeout – Timeout after which the analysis will be aborted Default: 25s

  • timestamp_field – Optional parameter to specify the timestamp field in the file

  • timestamp_format – Optional parameter to specify the timestamp format in the file - may be either a Joda or Java time format

Transforms

class elasticsearch.client.TransformClient(client)
delete_transform(transform_id, params=None, headers=None)

Deletes an existing transform.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/delete-transform.html

Parameters
  • transform_id – The id of the transform to delete

  • force – When true, the transform is deleted regardless of its current state. The default value is false, meaning that the transform must be stopped before it can be deleted.

  • timeout – Controls the time to wait for the transform deletion

get_transform(transform_id=None, params=None, headers=None)

Retrieves configuration information for transforms.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/get-transform.html

Parameters
  • transform_id – The id or comma delimited list of id expressions of the transforms to get, ‘_all’ or ‘*’ implies get 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)

  • exclude_generated – Omits fields that are illegal to set on transform PUT

  • from – skips a number of transform configs, defaults to 0

  • size – specifies a max number of transforms to get, defaults to 100

get_transform_stats(transform_id, params=None, headers=None)

Retrieves usage information for transforms.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/get-transform-stats.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)

  • from – skips a number of transform stats, defaults to 0

  • size – specifies a max number of transform stats to get, defaults to 100

preview_transform(body=None, transform_id=None, params=None, headers=None)

Previews a transform.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/preview-transform.html

Parameters
  • body – The definition for the transform to preview

  • transform_id – The id of the transform to preview.

  • timeout – Controls the time to wait for the preview

put_transform(transform_id, body, params=None, headers=None)

Instantiates a transform.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/put-transform.html

Parameters
  • transform_id – The id of the new transform.

  • body – The transform definition

  • defer_validation – If validations should be deferred until transform starts, defaults to false.

  • timeout – Controls the time to wait for the transform to start

start_transform(transform_id, params=None, headers=None)

Starts one or more transforms.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/start-transform.html

Parameters
  • transform_id – The id of the transform to start

  • timeout – Controls the time to wait for the transform to start

stop_transform(transform_id, params=None, headers=None)

Stops one or more transforms.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/stop-transform.html

Parameters
  • transform_id – The id of the transform to stop

  • allow_no_match – Whether to ignore if a wildcard expression matches no transforms. (This includes _all string or when no transforms have been specified)

  • force – Whether to force stop a failed transform or not. Default to false

  • timeout – Controls the time to wait until the transform has stopped. Default to 30 seconds

  • wait_for_checkpoint – Whether to wait for the transform to reach a checkpoint before stopping. Default to false

  • wait_for_completion – Whether to wait for the transform to fully stop before returning or not. Default to false

update_transform(transform_id, body, params=None, headers=None)

Updates certain properties of a transform.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/update-transform.html

Parameters
  • transform_id – The id of the transform.

  • body – The update transform definition

  • defer_validation – If validations should be deferred until transform starts, defaults to false.

  • timeout – Controls the time to wait for the update

upgrade_transforms(params=None, headers=None)

Upgrades all transforms.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/upgrade-transforms.html

Parameters
  • dry_run – Whether to only check for updates but don’t execute

  • timeout – Controls the time to wait for the upgrade

Watcher

class elasticsearch.client.WatcherClient(client)
ack_watch(watch_id, action_id=None, params=None, headers=None)

Acknowledges a watch, manually throttling the execution of the watch’s actions.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/watcher-api-ack-watch.html

Parameters
  • watch_id – Watch ID

  • action_id – A comma-separated list of the action ids to be acked

activate_watch(watch_id, params=None, headers=None)

Activates a currently inactive watch.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/watcher-api-activate-watch.html

Parameters

watch_id – Watch ID

deactivate_watch(watch_id, params=None, headers=None)

Deactivates a currently active watch.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/watcher-api-deactivate-watch.html

Parameters

watch_id – Watch ID

delete_watch(id, params=None, headers=None)

Removes a watch from Watcher.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/watcher-api-delete-watch.html

Parameters

id – Watch ID

execute_watch(body=None, id=None, params=None, headers=None)

Forces the execution of a stored watch.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/watcher-api-execute-watch.html

Parameters
  • body – Execution control

  • id – Watch ID

  • debug – indicates whether the watch should execute in debug mode

get_watch(id, params=None, headers=None)

Retrieves a watch by its ID.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/watcher-api-get-watch.html

Parameters

id – Watch ID

put_watch(id, body=None, params=None, headers=None)

Creates a new watch, or updates an existing one.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/watcher-api-put-watch.html

Parameters
  • id – Watch ID

  • body – The watch

  • active – Specify whether the watch is in/active by default

  • if_primary_term – only update the watch if the last operation that has changed the watch has the specified primary term

  • if_seq_no – only update the watch if the last operation that has changed the watch has the specified sequence number

  • version – Explicit version number for concurrency control

query_watches(body=None, params=None, headers=None)

Retrieves stored watches.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/watcher-api-query-watches.html

Parameters

body – From, size, query, sort and search_after

start(params=None, headers=None)

Starts Watcher if it is not already running.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/watcher-api-start.html

stats(metric=None, params=None, headers=None)

Retrieves the current Watcher metrics.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/watcher-api-stats.html

Parameters
  • metric – Controls what additional stat metrics should be include in the response Valid choices: _all, queued_watches, current_watches, pending_watches

  • emit_stacktraces – Emits stack traces of currently running watches

stop(params=None, headers=None)

Stops Watcher if it is running.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/watcher-api-stop.html

X-Pack

class elasticsearch.client.XPackClient(client)
info(params=None, headers=None)

Retrieves information about the installed X-Pack features.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/info-api.html

Parameters
  • accept_enterprise – If an enterprise license is installed, return the type and mode as ‘enterprise’ (default: false)

  • categories – Comma-separated list of info categories. Can be any of: build, license, features

usage(params=None, headers=None)

Retrieves usage information about the installed X-Pack features.

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/usage-api.html

Parameters

master_timeout – Specify timeout for watch write operation