API Documentation¶
All the API calls map the raw REST api as closely as possible, including the distinction between required and optional arguments to the calls. This means that the code makes distinction between positional and keyword arguments; we, however, recommend that people use keyword arguments for all calls for consistency and safety.
Note
for compatibility with the Python ecosystem we use from_
instead of
from
and doc_type
instead of type
as parameter names.
Global options¶
Some parameters are added by the client itself and can be used in all API calls.
Ignore¶
An API call is considered successful (and will return a response) if
elasticsearch returns a 2XX response. Otherwise an instance of
TransportError
(or a more specific subclass) will be
raised. You can see other exception and error states in Exceptions. If
you do not wish an exception to be raised you can always pass in an ignore
parameter with either a single status code that should be ignored or a list of
them:
from elasticsearch import Elasticsearch
es = Elasticsearch()
# ignore 400 cause by IndexAlreadyExistsException when creating an index
es.indices.create(index='test-index', ignore=400)
# ignore 404 and 400
es.indices.delete(index='test-index', ignore=[400, 404])
Timeout¶
Global timeout can be set when constructing the client (see
Connection
’s timeout
parameter) or on a per-request
basis using request_timeout
(float value in seconds) as part of any API
call, this value will get passed to the perform_request
method of the
connection class:
# only wait for 1 second, regardless of the client's default
es.cluster.health(wait_for_status='yellow', request_timeout=1)
Note
Some API calls also accept a timeout
parameter that is passed to
Elasticsearch server. This timeout is internal and doesn’t guarantee that the
request will end in the specified time.
Response Filtering¶
The filter_path
parameter is used to reduce the response returned by
elasticsearch. For example, to only return _id
and _type
, do:
es.search(index='test-index', filter_path=['hits.hits._id', 'hits.hits._type'])
It also supports the *
wildcard character to match any field or part of a
field’s name:
es.search(index='test-index', filter_path=['hits.hits._*'])
Elasticsearch¶
-
class
elasticsearch.
Elasticsearch
(hosts=None, transport_class=<class 'elasticsearch.transport.Transport'>, **kwargs)¶ Elasticsearch low-level client. Provides a straightforward mapping from Python to ES REST endpoints.
The instance has attributes
cat
,cluster
,indices
,ingest
,nodes
,snapshot
andtasks
that provide access to instances ofCatClient
,ClusterClient
,IndicesClient
,IngestClient
,NodesClient
,SnapshotClient
andTasksClient
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 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 ofhost[:port]
which will be translated to a dictionary automatically. If no value is given theUrllib3HttpConnection
class defaults will be used.transport_class –
Transport
subclass to use.kwargs – any additional arguments will be passed on to the
Transport
class and, subsequently, to theConnection
instances.
-
bulk
(body, doc_type=None, index=None, params=None)¶ Perform many index/delete operations in a single API call.
See the
bulk()
helper function for a more friendly API. http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html- Parameters
body – The operation definition and data (action-data pairs), separated by newlines
index – Default index for items which don’t provide one
_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
fields – Default comma-separated list of fields to return in the response for updates, can be overridden on each sub-request
pipeline – The pipeline id to preprocess incoming documents with
refresh – If true then refresh the effected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false (the default) then do nothing with refreshes., valid choices are: ‘true’, ‘false’, ‘wait_for’
routing – Specific routing value
timeout – Explicit operation timeout
wait_for_active_shards – Sets the number of shard copies that must be active before proceeding with the bulk operation. Defaults to 1, meaning the primary shard only. Set to all for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
-
clear_scroll
(scroll_id=None, body=None, params=None)¶ Clear the scroll request created by specifying the scroll parameter to search. http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html
- Parameters
scroll_id – A comma-separated list of scroll IDs to clear
body – A comma-separated list of scroll IDs to clear if none was specified via the scroll_id parameter
-
count
(doc_type=None, index=None, body=None, params=None)¶ Execute a query and get the number of matches for that query. http://www.elastic.co/guide/en/elasticsearch/reference/current/search-count.html
- Parameters
index – A list of index names or a string containing a comma-separated list of index names to restrict the results to
body – A query to restrict the results specified with the Query DSL (optional)
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
analyze_wildcard – Specify whether wildcard and prefix queries should be analyzed (default: false)
analyzer – The analyzer to use for the query string
default_operator – The default operator for query string query (AND or OR), default ‘OR’, valid choices are: ‘AND’, ‘OR’
df – The field to use as default where no field prefix is given in the query string
expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
ignore_throttled – Whether specified concrete, expanded or aliased indices should be ignored when throttled
lenient – Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
min_score – Include only documents with a specific _score value in the result
preference – Specify the node or shard the operation should be performed on (default: random)
q – Query in the Lucene query string syntax
routing – Specific routing value
-
create
(index, id, body, doc_type='_doc', params=None)¶ Adds a typed JSON document in a specific index, making it searchable. Behind the scenes this method calls index(…, op_type=’create’) http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html
- Parameters
index – The name of the index
id – Document ID
body – The document
parent – ID of the parent document
pipeline – The pipeline id to preprocess incoming documents with
refresh – If true then refresh the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false (the default) then do nothing with refreshes., valid choices are: ‘true’, ‘false’, ‘wait_for’
routing – Specific routing value
timeout – Explicit operation timeout
timestamp – Explicit timestamp for the document
ttl – Expiration time for the document
version – Explicit version number for concurrency control
version_type – Specific version type, valid choices are: ‘internal’, ‘external’, ‘external_gte’, ‘force’
wait_for_active_shards – Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to all for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
-
delete
(index, id, doc_type='_doc', params=None)¶ Delete a typed JSON document from a specific index based on its id. http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete.html
- Parameters
index – The name of the index
id – The document ID
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
parent – ID of parent document
refresh – If true then refresh the effected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false (the default) then do nothing with refreshes., valid choices are: ‘true’, ‘false’, ‘wait_for’
routing – Specific routing value
timeout – Explicit operation timeout
version – Explicit version number for concurrency control
version_type – Specific version type, valid choices are: ‘internal’, ‘external’, ‘external_gte’, ‘force’
wait_for_active_shards – Sets the number of shard copies that must be active before proceeding with the delete operation. Defaults to 1, meaning the primary shard only. Set to all for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
-
delete_by_query
(index, body, params=None)¶ Delete all documents matching a query. https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html
- Parameters
index – A list of index names to search, or a string containing a comma-separated list of index names to search; use _all or the empty string to perform the operation on all indices
body – The search definition using the Query DSL
_source – True or false to return the _source field or not, or a list of fields to return
_source_excludes – A list of fields to exclude from the returned _source field
_source_includes – A list of fields to extract and return from the _source field
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
analyze_wildcard – Specify whether wildcard and prefix queries should be analyzed (default: false)
analyzer – The analyzer to use for the query string
conflicts – What to do when the delete-by-query hits version conflicts?, default ‘abort’, valid choices are: ‘abort’, ‘proceed’
default_operator – The default operator for query string query (AND or OR), default ‘OR’, valid choices are: ‘AND’, ‘OR’
df – The field to use as default where no field prefix is given in the query string
expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
from_ – Starting offset (default: 0)
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
lenient – Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
preference – Specify the node or shard the operation should be performed on (default: random)
q – Query in the Lucene query string syntax
refresh – Should the effected indexes be refreshed?
request_cache – Specify if request cache should be used for this request or not, defaults to index level setting
requests_per_second – The throttle for this request in sub-requests per second. -1 means no throttle., default 0
routing – A comma-separated list of specific routing values
scroll – Specify how long a consistent view of the index should be maintained for scrolled search
scroll_size – Size on the scroll request powering the update_by_query
search_timeout – Explicit timeout for each search request. Defaults to no timeout.
search_type – Search operation type, valid choices are: ‘query_then_fetch’, ‘dfs_query_then_fetch’
size – Number of hits to return (default: 10)
slices – The number of slices this task should be divided into. Defaults to 1 meaning the task isn’t sliced into subtasks., default 1
sort – A comma-separated list of <field>:<direction> pairs
stats – Specific ‘tag’ of the request for logging and statistical purposes
terminate_after – The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
timeout – Time each individual bulk request should wait for shards that are unavailable., default ‘1m’
version – Specify whether to return document version as part of a hit
wait_for_active_shards – Sets the number of shard copies that must be active before proceeding with the delete by query operation. Defaults to 1, meaning the primary shard only. Set to all for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
wait_for_completion – Should the request should block until the delete-by-query is complete., default True
-
delete_by_query_rethrottle
(task_id, params=None)¶ https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html
- Parameters
task_id – The task id to rethrottle
requests_per_second – The throttle to set on this request in floating sub-requests per second. -1 means set no throttle.
-
delete_script
(id, params=None)¶ Remove a stored script from elasticsearch. http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html
- Parameters
id – Script ID
master_timeout – Specify timeout for connection to master
timeout – Explicit operation timeout
-
exists
(index, id, doc_type='_doc', params=None)¶ Returns a boolean indicating whether or not given document exists in Elasticsearch. http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html
- Parameters
index – The name of the index
id – The document ID
_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
parent – The ID of the parent document
preference – Specify the node or shard the operation should be performed on (default: random)
realtime – Specify whether to perform the operation in realtime or search mode
refresh – Refresh the shard containing the document before performing the operation
routing – Specific routing value
stored_fields – A comma-separated list of stored fields to return in the response
version – Explicit version number for concurrency control
version_type – Specific version type, valid choices are: ‘internal’, ‘external’, ‘external_gte’, ‘force’
-
exists_source
(index, id, doc_type=None, params=None)¶ http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html
- Parameters
index – The name of the index
id – The document ID
_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
parent – The ID of the parent document
preference – Specify the node or shard the operation should be performed on (default: random)
realtime – Specify whether to perform the operation in realtime or search mode
refresh – Refresh the shard containing the document before performing the operation
routing – Specific routing value
version – Explicit version number for concurrency control
version_type – Specific version type, valid choices are: ‘internal’, ‘external’, ‘external_gte’, ‘force’
-
explain
(index, id, doc_type='_doc', body=None, params=None)¶ The explain api computes a score explanation for a query and a specific document. This can give useful feedback whether a document matches or didn’t match a specific query. http://www.elastic.co/guide/en/elasticsearch/reference/current/search-explain.html
- Parameters
index – The name of the index
id – The document ID
body – The query definition using the Query DSL
_source – True or false to return the _source field or not, or a list of fields to return
_source_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), default ‘OR’, valid choices are: ‘AND’, ‘OR’
df – The default field for query string query (default: _all)
lenient – Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
parent – The ID of the parent document
preference – Specify the node or shard the operation should be performed on (default: random)
q – Query in the Lucene query string syntax
routing – Specific routing value
stored_fields – A comma-separated list of stored fields to return in the response
-
field_caps
(index=None, body=None, params=None)¶ The field capabilities API allows to retrieve the capabilities of fields among multiple indices. http://www.elastic.co/guide/en/elasticsearch/reference/current/search-field-caps.html
- Parameters
index – A list of index names, or a string containing a comma-separated list of index names; use _all or the empty string to perform the operation on all indices
body – Field json objects containing an array of field names
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
fields – A comma-separated list of field names
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
include_unmapped – Indicates whether unmapped fields should be included in the response., default False
-
get
(index, id, doc_type='_doc', params=None)¶ Get a typed JSON document from the index based on its id. http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html
- Parameters
index – The name of the index
id – The document ID
_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
parent – The ID of the parent document
preference – Specify the node or shard the operation should be performed on (default: random)
realtime – Specify whether to perform the operation in realtime or search mode
refresh – Refresh the shard containing the document before performing the operation
routing – Specific routing value
stored_fields – A comma-separated list of stored fields to return in the response
version – Explicit version number for concurrency control
version_type – Specific version type, valid choices are: ‘internal’, ‘external’, ‘external_gte’, ‘force’
-
get_script
(id, params=None)¶ Retrieve a script from the API. http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html
- Parameters
id – Script ID
master_timeout – Specify timeout for connection to master
-
get_source
(index, id, doc_type='_doc', params=None)¶ Get the source of a document by it’s index, type and id. http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html
- Parameters
index – The name of the index
id – The document ID
_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
parent – The ID of the parent document
preference – Specify the node or shard the operation should be performed on (default: random)
realtime – Specify whether to perform the operation in realtime or search mode
refresh – Refresh the shard containing the document before performing the operation
routing – Specific routing value
version – Explicit version number for concurrency control
version_type – Specific version type, valid choices are: ‘internal’, ‘external’, ‘external_gte’, ‘force’
-
index
(index, body, doc_type='_doc', id=None, params=None)¶ Adds or updates a typed JSON document in a specific index, making it searchable. http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html
- Parameters
index – The name of the index
body – 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
doc_type – Document type, defaults to _doc. Not used on ES 7 clusters.
op_type – Explicit operation type, default ‘index’, valid choices are: ‘index’, ‘create’
parent – ID of the parent document
pipeline – The pipeline id to preprocess incoming documents with
refresh – If true then refresh the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false (the default) then do nothing with refreshes., valid choices are: ‘true’, ‘false’, ‘wait_for’
routing – Specific routing value
timeout – Explicit operation timeout
timestamp – Explicit timestamp for the document
ttl – Expiration time for the document
version – Explicit version number for concurrency control
version_type – Specific version type, valid choices are: ‘internal’, ‘external’, ‘external_gte’, ‘force’
wait_for_active_shards – Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to all for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
-
info
(params=None)¶ Get the basic info from the current cluster. http://www.elastic.co/guide/
-
mget
(body, doc_type=None, index=None, params=None)¶ Get multiple documents based on an index, type (optional) and ids. http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.html
- Parameters
body – Document identifiers; can be either docs (containing full document information) or ids (when index and type is provided in the URL.
index – The name of the index
_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, params=None)¶ Execute several search requests within the same API. http://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html
- Parameters
body – The request definitions (metadata-search request definition pairs), separated by newlines
index – A list of index names, or a string containing a comma-separated list of index names, to use as the 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
pre_filter_shard_size – A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on it’s rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint., default 128
search_type – Search operation type, valid choices are: ‘query_then_fetch’, ‘query_and_fetch’, ‘dfs_query_then_fetch’, ‘dfs_query_and_fetch’
typed_keys – Specify whether aggregation and suggester names should be prefixed by their respective types in the response
-
msearch_template
(body, index=None, params=None)¶ The /_search/template endpoint allows to use the mustache language to pre render search requests, before they are executed and fill existing templates with template parameters. http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html
- Parameters
body – The request definitions (metadata-search request definition pairs), separated by newlines
index – A list of index names, or a string containing a comma-separated list of index names, to use as the 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
search_type – Search operation type, valid choices are: ‘query_then_fetch’, ‘query_and_fetch’, ‘dfs_query_then_fetch’, ‘dfs_query_and_fetch’
typed_keys – Specify whether aggregation and suggester names should be prefixed by their respective types in the response
-
mtermvectors
(doc_type=None, index=None, body=None, params=None)¶ Multi termvectors API allows to get multiple termvectors based on an index, type and id. http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-termvectors.html
- Parameters
index – The index in which the document resides.
body – Define ids, documents, parameters or a list of parameters per document here. You must at least provide a list of document ids. See documentation.
field_statistics – Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified in body “params” or “docs”., default True
fields – A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body “params” or “docs”.
ids – A comma-separated list of documents ids. You must define ids as parameter or set “ids” or “docs” in the request body
offsets – Specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body “params” or “docs”., default True
parent – Parent id of documents. Applies to all returned documents unless otherwise specified in body “params” or “docs”.
payloads – Specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body “params” or “docs”., default True
positions – Specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body “params” or “docs”., default True
preference – Specify the node or shard the operation should be performed on (default: random) .Applies to all returned documents unless otherwise specified in body “params” or “docs”.
realtime – Specifies if requests are real-time as opposed to near- real-time (default: true).
routing – Specific routing value. Applies to all returned documents unless otherwise specified in body “params” or “docs”.
term_statistics – Specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body “params” or “docs”., default False
version – Explicit version number for concurrency control
version_type – Specific version type, valid choices are: ‘internal’, ‘external’, ‘external_gte’, ‘force’
-
ping
(params=None)¶ Returns True if the cluster is up, False otherwise. http://www.elastic.co/guide/
-
put_script
(id, body, context=None, params=None)¶ Create a script in given language with specified ID. http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html
- Parameters
id – Script ID
body – The document
master_timeout – Specify timeout for connection to master
timeout – Explicit operation timeout
-
rank_eval
(body, index=None, params=None)¶ https://www.elastic.co/guide/en/elasticsearch/reference/master/search-rank-eval.html
- Parameters
body – The ranking evaluation search definition, including search requests, document ratings and ranking metric definition.
index – A comma-separated list of index names to search; use _all or empty string to perform the operation on all indices
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
-
reindex
(body, params=None)¶ Reindex all documents from one index to another. https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html
- Parameters
body – The search definition using the Query DSL and the prototype for the index request.
refresh – Should the effected indexes be refreshed?
requests_per_second – The throttle to set on this request in sub- requests per second. -1 means no throttle., default 0
slices – The number of slices this task should be divided into. Defaults to 1 meaning the task isn’t sliced into subtasks., default 1
scroll – Control how long to keep the search context alive, default ‘5m’
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=None, params=None)¶ Change the value of
requests_per_second
of a runningreindex
task. https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html- Parameters
task_id – The task id to rethrottle
requests_per_second – The throttle to set on this request in floating sub-requests per second. -1 means set no throttle.
-
render_search_template
(id=None, body=None, params=None)¶ http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-template.html
- Parameters
id – The id of the stored search template
body – The search definition template and its params
-
scripts_painless_context
(params=None)¶ -
- Parameters
context – Select a specific context to retrieve API information about
-
scripts_painless_execute
(body=None, params=None)¶ https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-execute-api.html
- Parameters
body – The script to execute
-
scroll
(body=None, scroll_id=None, params=None)¶ Scroll a search request created by specifying the scroll parameter. http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html
- Parameters
scroll_id – The scroll ID
body – The scroll ID if not passed by URL or query parameter.
scroll – Specify how long a consistent view of the index should be maintained for scrolled search
rest_total_hits_as_int – This parameter is used to restore the total hits as a number in the response. This param is added version 6.x to handle mixed cluster queries where nodes are in multiple versions (7.0 and 6.latest)
-
search
(index=None, body=None, params=None)¶ Execute a search query and get back search hits that match the query. http://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html
- Parameters
index – A list of index names to search, or a string containing 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
_source – True or false to return the _source field or not, or a list of fields to return
_source_excludes – A list of fields to exclude from the returned _source field
_source_includes – A list of fields to extract and return from the _source field
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
allow_partial_search_results – Set to false to return an overall failure if the request would produce partial results. Defaults to True, which will allow partial results in the case of timeouts or partial failures
analyze_wildcard – Specify whether wildcard and prefix queries should be analyzed (default: false)
analyzer – The analyzer to use for the query string
batched_reduce_size – The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large., default 512
ccs_minimize_roundtrips – Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution, default ‘true’
default_operator – The default operator for query string query (AND or OR), default ‘OR’, valid choices are: ‘AND’, ‘OR’
df – The field to use as default where no field prefix is given in the query string
docvalue_fields – A comma-separated list of fields to return as the docvalue representation of a field for each hit
expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
explain – Specify whether to return detailed information about score computation as part of a hit
from_ – Starting offset (default: 0)
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
lenient – Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
max_concurrent_shard_requests – The number of concurrent shard requests this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests, default ‘The default grows with the number of nodes in the cluster but is at most 256.’
pre_filter_shard_size – A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on it’s rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint., default 128
preference – Specify the node or shard the operation should be performed on (default: random)
q – Query in the Lucene query string syntax
rest_total_hits_as_int – This parameter is used to restore the total hits as a number in the response. This param is added version 6.x to handle mixed cluster queries where nodes are in multiple versions (7.0 and 6.latest)
request_cache – Specify if request cache should be used for this request or not, defaults to index level setting
routing – A comma-separated list of specific routing values
scroll – Specify how long a consistent view of the index should be maintained for scrolled search
search_type – Search operation type, valid choices are: ‘query_then_fetch’, ‘dfs_query_then_fetch’
size – Number of hits to return (default: 10)
sort – A comma-separated list of <field>:<direction> pairs
stats – Specific ‘tag’ of the request for logging and statistical purposes
stored_fields – A comma-separated list of stored fields to return as part of a hit
suggest_field – Specify which field to use for suggestions
suggest_mode – Specify suggest mode, default ‘missing’, valid choices are: ‘missing’, ‘popular’, ‘always’
suggest_size – How many suggestions to return in response
suggest_text – The source text for which the suggestions should be returned
terminate_after – The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
timeout – Explicit operation timeout
track_scores – Whether to calculate and return scores even if they are not used for sorting
track_total_hits – Indicate if the number of documents that match the query should be tracked
typed_keys – Specify whether aggregation and suggester names should be prefixed by their respective types in the response
version – Specify whether to return document version as part of a hit
-
search_shards
(index=None, params=None)¶ The search shards api returns the indices and shards that a search request would be executed against. This can give useful feedback for working out issues or planning optimizations with routing and shard preferences. http://www.elastic.co/guide/en/elasticsearch/reference/current/search-shards.html
- Parameters
index – A list of index names to search, or a string containing a comma-separated list of index names to search; use _all or the empty string to perform the operation on all indices
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
local – Return local information, do not retrieve the state from master node (default: false)
preference – Specify the node or shard the operation should be performed on (default: random)
routing – Specific routing value
-
search_template
(index=None, body=None, params=None)¶ A query that accepts a query template and a map of key/value pairs to fill in template parameters. http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html
- Parameters
index – A list of index names to search, or a string containing a comma-separated list of index names to search; use _all or the empty string to perform the operation on all indices
body – The search definition template and its params
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
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., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
explain – Specify whether to return detailed information about score computation as part of a hit
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
preference – Specify the node or shard the operation should be performed on (default: random)
profile – Specify whether to profile the query execution
routing – A comma-separated list of specific routing values
rest_total_hits_as_int – Indicates whether hits.total should be rendered as an integer or an object in the rest search response, default False
scroll – Specify how long a consistent view of the index should be maintained for scrolled search
search_type – Search operation type, valid choices are: ‘query_then_fetch’, ‘query_and_fetch’, ‘dfs_query_then_fetch’, ‘dfs_query_and_fetch’
typed_keys – Specify whether aggregation and suggester names should be prefixed by their respective types in the response
-
termvectors
(index, doc_type='_doc', id=None, body=None, params=None)¶ Returns information and statistics on terms in the fields of a particular document. The document could be stored in the index or artificially provided by the user (Added in 1.4). Note that for documents stored in the index, this is a near realtime API as the term vectors are not available until the next refresh. http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-termvectors.html
- Parameters
index – The index in which the document resides.
id – The id of the document, when not specified a doc param should be supplied.
body – Define parameters and or supply a document to get termvectors for. See documentation.
field_statistics – Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned., default True
fields – A comma-separated list of fields to return.
offsets – Specifies if term offsets should be returned., default True
parent – Parent id of documents.
payloads – Specifies if term payloads should be returned., default True
positions – Specifies if term positions should be returned., default True
preference – Specify the node or shard the operation should be performed on (default: random).
realtime – Specifies if request is real-time as opposed to near- real-time (default: true).
routing – Specific routing value.
term_statistics – Specifies if total term frequency and document frequency should be returned., default False
version – Explicit version number for concurrency control
version_type – Specific version type, valid choices are: ‘internal’, ‘external’, ‘external_gte’, ‘force’
-
update
(index, id, doc_type='_doc', body=None, params=None)¶ Update a document based on a script or partial data provided. http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html
- Parameters
index – The name of the index
id – Document ID
body – The request definition using either script or partial doc
_source – True or false to return the _source field or not, or a list of fields to return
_source_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
fields – A comma-separated list of fields to return in the response
if_seq_no –
if_primary_term –
lang – The script language (default: painless)
parent – ID of the parent document. Is is only used for routing and when for the upsert request
refresh – If true then refresh the effected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false (the default) then do nothing with refreshes., valid choices are: ‘true’, ‘false’, ‘wait_for’
retry_on_conflict – Specify how many times should the operation be retried when a conflict occurs (default: 0)
routing – Specific routing value
timeout – Explicit operation timeout
timestamp – Explicit timestamp for the document
ttl – Expiration time for the document
version – Explicit version number for concurrency control
version_type – Specific version type, valid choices are: ‘internal’, ‘force’
wait_for_active_shards – Sets the number of shard copies that must be active before proceeding with the update operation. Defaults to 1, meaning the primary shard only. Set to all for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
-
update_by_query
(index, body=None, params=None)¶ Perform an update on all documents matching a query. https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html
- Parameters
index – A list of index names to search, or a string containing a comma-separated list of index names to search; use _all or the empty string to perform the operation on all indices
body – The search definition using the Query DSL
_source – True or false to return the _source field or not, or a list of fields to return
_source_excludes – A list of fields to exclude from the returned _source field
_source_includes – A list of fields to extract and return from the _source field
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
analyze_wildcard – Specify whether wildcard and prefix queries should be analyzed (default: false)
analyzer – The analyzer to use for the query string
conflicts – What to do when the update by query hits version conflicts?, default ‘abort’, valid choices are: ‘abort’, ‘proceed’
default_operator – The default operator for query string query (AND or OR), default ‘OR’, valid choices are: ‘AND’, ‘OR’
df – The field to use as default where no field prefix is given in the query string
expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
from_ – Starting offset (default: 0)
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
lenient – Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
pipeline – Ingest pipeline to set on index requests made by this action. (default: none)
preference – Specify the node or shard the operation should be performed on (default: random)
q – Query in the Lucene query string syntax
refresh – Should the effected indexes be refreshed?
request_cache – Specify if request cache should be used for this request or not, defaults to index level setting
requests_per_second – The throttle to set on this request in sub- requests per second. -1 means no throttle., default 0
routing – A comma-separated list of specific routing values
scroll – Specify how long a consistent view of the index should be maintained for scrolled search
scroll_size – Size on the scroll request powering the update_by_query
search_timeout – Explicit timeout for each search request. Defaults to no timeout.
search_type – Search operation type, valid choices are: ‘query_then_fetch’, ‘dfs_query_then_fetch’
size – Number of hits to return (default: 10)
slices – The number of slices this task should be divided into. Defaults to 1 meaning the task isn’t sliced into subtasks., default 1
sort – A comma-separated list of <field>:<direction> pairs
stats – Specific ‘tag’ of the request for logging and statistical purposes
terminate_after – The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
timeout – Time each individual bulk request should wait for shards that are unavailable., default ‘1m’
version – Specify whether to return document version as part of a hit
version_type – Should the document increment the version number (internal) on hit or not (reindex)
wait_for_active_shards – Sets the number of shard copies that must be active before proceeding with the update by query operation. Defaults to 1, meaning the primary shard only. Set to all for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
wait_for_completion – Should the request should block until the update by query operation is complete., default True
-
update_by_query_rethrottle
(task_id, params=None)¶ https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html
- Parameters
task_id – The task id to rethrottle
requests_per_second – The throttle to set on this request in floating sub-requests per second. -1 means set no throttle.
Indices¶
-
class
elasticsearch.client.
IndicesClient
(client)¶ -
analyze
(index=None, body=None, params=None)¶ Perform the analysis process on a text and return the tokens breakdown of the text. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-analyze.html
- Parameters
index – The name of the index to scope the operation
body – Define analyzer/tokenizer parameters and the text on which the analysis should be performed
format – Format of the output, default ‘detailed’, valid choices are: ‘detailed’, ‘text’
prefer_local – With true, specify that a local shard should be used if available, with false, use a random shard (default: true)
-
clear_cache
(index=None, params=None)¶ Clear either all caches or specific cached associated with one ore more indices. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-clearcache.html
- Parameters
index – A comma-separated list of index name to limit the operation
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
field_data – Clear field data
fielddata – Clear field data
fields – A comma-separated list of fields to clear when using the field_data parameter (default: all)
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
query – Clear query caches
recycler – Clear the recycler cache
request – Clear request cache
request_cache – Clear request cache
-
clone
(index, target, body=None, params=None)¶ Clones an index https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-clone-index.html
- Parameters
index – The name of the source index to clone
target – The name of the target index to clone into
master_timeout – Specify timeout for connection to master
timeout – Explicit operation timeout
wait_for_active_shards – Set the number of active shards to wait for before the operation returns.
-
close
(index, params=None)¶ Close an index to remove it’s overhead from the cluster. Closed index is blocked for read/write operations. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html
- Parameters
index – The name of the index
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
master_timeout – Specify timeout for connection to master
wait_for_active_shards – Sets the number of active shards to wait for before the operation returns.
-
create
(index, body=None, params=None)¶ Create an index in Elasticsearch. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html
- Parameters
index – The name of the index
body – The configuration for the index (settings and mappings)
master_timeout – Specify timeout for connection to master
timeout – Explicit operation timeout
wait_for_active_shards – Set the number of active shards to wait for before the operation returns.
include_type_name – Specify whether requests and responses should include a type name (default: depends on Elasticsearch version).
-
delete
(index, params=None)¶ Delete an index in Elasticsearch http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-delete-index.html
- Parameters
index – A comma-separated list of indices to delete; use _all or * string to delete all indices
allow_no_indices – Ignore if a wildcard expression resolves to no concrete indices (default: false)
expand_wildcards – Whether wildcard expressions should get expanded to open or closed indices (default: open), default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
ignore_unavailable – Ignore unavailable indexes (default: false)
master_timeout – Specify timeout for connection to master
timeout – Explicit operation timeout
-
delete_alias
(index, name, params=None)¶ Delete specific alias. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html
- Parameters
index – A comma-separated list of index names (supports wildcards); use _all for all indices
name – A comma-separated list of aliases to delete (supports wildcards); use _all to delete all aliases for the specified indices.
master_timeout – Specify timeout for connection to master
timeout – Explicit timeout for the operation
-
delete_template
(name, params=None)¶ Delete an index template by its name. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html
- Parameters
name – The name of the template
master_timeout – Specify timeout for connection to master
timeout – Explicit operation timeout
-
exists
(index, params=None)¶ Return a boolean indicating whether given index exists. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-exists.html
- Parameters
index – A comma-separated list of index names
allow_no_indices – Ignore if a wildcard expression resolves to no concrete indices (default: false)
expand_wildcards – Whether wildcard expressions should get expanded to open or closed indices (default: open), default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
flat_settings – Return settings in flat format (default: false)
ignore_unavailable – Ignore unavailable indexes (default: false)
include_defaults – Whether to return all default setting for each of the indices., default False
local – Return local information, do not retrieve the state from master node (default: false)
-
exists_alias
(index=None, name=None, params=None)¶ Return a boolean indicating whether given alias exists. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html
- Parameters
index – A comma-separated list of index names to filter aliases
name – A comma-separated list of alias names to return
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘all’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
local – Return local information, do not retrieve the state from master node (default: false)
-
exists_template
(name, params=None)¶ Return a boolean indicating whether given template exists. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html
- Parameters
name – The comma separated names of the index templates
flat_settings – Return settings in flat format (default: false)
local – Return local information, do not retrieve the state from master node (default: false)
master_timeout – Explicit operation timeout for connection to master node
-
exists_type
(index, doc_type, params=None)¶ Check if a type/types exists in an index/indices. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-types-exists.html
- Parameters
index – A comma-separated list of index names; use _all to check the types across all indices
doc_type – A comma-separated list of document types to check
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
local – Return local information, do not retrieve the state from master node (default: false)
-
flush
(index=None, params=None)¶ Explicitly flush one or more indices. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-flush.html
- Parameters
index – A comma-separated list of index names; use _all or empty string for all indices
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
force – Whether a flush should be forced even if it is not necessarily needed ie. if no changes will be committed to the index. This is useful if transaction log IDs should be incremented even if no uncommitted changes are present. (This setting can be considered as internal)
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
wait_if_ongoing – If set to true the flush operation will block until the flush can be executed if another flush operation is already executing. The default is true. If set to false the flush will be skipped iff if another flush operation is already running.
-
flush_synced
(index=None, params=None)¶ Perform a normal flush, then add a generated unique marker (sync_id) to all shards. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-synced-flush.html
- Parameters
index – A comma-separated list of index names; use _all or empty string for all indices
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
-
forcemerge
(index=None, params=None)¶ The force merge API allows to force merging of one or more indices through an API. The merge relates to the number of segments a Lucene index holds within each shard. The force merge operation allows to reduce the number of segments by merging them.
This call will block until the merge is complete. If the http connection is lost, the request will continue in the background, and any new requests will block until the previous force merge is complete. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-forcemerge.html
- Parameters
index – A comma-separated list of index names; use _all or empty string to perform the operation on all indices
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
flush – Specify whether the index should be flushed after performing the operation (default: true)
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
max_num_segments – The number of segments the index should be merged into (default: dynamic)
only_expunge_deletes – Specify whether the operation should only expunge deleted documents (for pre 7.x ES clusters)
-
freeze
(index, params=None)¶ https://www.elastic.co/guide/en/elasticsearch/reference/current/frozen.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., default ‘closed’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
master_timeout – Specify timeout for connection to master
timeout – Explicit operation timeout
wait_for_active_shards – Sets the number of active shards to wait for before the operation returns.
-
get
(index, feature=None, params=None)¶ The get index API allows to retrieve information about one or more indexes. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-index.html
- Parameters
index – A comma-separated list of index names
allow_no_indices – Ignore if a wildcard expression resolves to no concrete indices (default: false)
expand_wildcards – Whether wildcard expressions should get expanded to open or closed indices (default: open), default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
flat_settings – Return settings in flat format (default: false)
ignore_unavailable – Ignore unavailable indexes (default: false)
include_defaults – Whether to return all default setting for each of the indices., default False
local – Return local information, do not retrieve the state from master node (default: false)
include_type_name – Specify whether requests and responses should include a type name (default: depends on Elasticsearch version).
master_timeout – Specify timeout for connection to master
-
get_alias
(index=None, name=None, params=None)¶ Retrieve a specified alias. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html
- Parameters
index – A comma-separated list of index names to filter aliases
name – A comma-separated list of alias names to return
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘all’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
local – Return local information, do not retrieve the state from master node (default: false)
-
get_field_mapping
(fields, index=None, doc_type=None, params=None)¶ Retrieve mapping definition of a specific field. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-field-mapping.html
- Parameters
fields – A comma-separated list of fields
index – A comma-separated list of index names
doc_type – A comma-separated list of document types
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
include_defaults – Whether the default mapping values should be returned as well
local – Return local information, do not retrieve the state from master node (default: false)
include_type_name – Specify whether requests and responses should include a type name (default: depends on Elasticsearch version).
-
get_mapping
(index=None, doc_type=None, params=None)¶ Retrieve mapping definition of index or index/type. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-mapping.html
- Parameters
index – A comma-separated list of index names
doc_type – A comma-separated list of document types
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
local – Return local information, do not retrieve the state from master node (default: false)
include_type_name – Specify whether requests and responses should include a type name (default: depends on Elasticsearch version).
master_timeout – Specify timeout for connection to master
-
get_settings
(index=None, name=None, params=None)¶ Retrieve settings for one or more (or all) indices. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-settings.html
- Parameters
index – A comma-separated list of index names; use _all or empty string to perform the operation on all indices
name – The name of the settings that should be included
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default [‘open’, ‘closed’], valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
flat_settings – Return settings in flat format (default: false)
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
include_defaults – Whether to return all default setting for each of the indices., default False
local – Return local information, do not retrieve the state from master node (default: false)
master_timeout – Specify timeout for connection to master
-
get_template
(name=None, params=None)¶ Retrieve an index template by its name. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html
- Parameters
name – The name of the template
flat_settings – Return settings in flat format (default: false)
local – Return local information, do not retrieve the state from master node (default: false)
master_timeout – Explicit operation timeout for connection to master node
include_type_name – Specify whether requests and responses should include a type name (default: depends on Elasticsearch version).
-
get_upgrade
(index=None, params=None)¶ Monitor how much of one or more index is upgraded. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-upgrade.html
- Parameters
index – A comma-separated list of index names; use _all or empty string to perform the operation on all indices
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
-
open
(index, params=None)¶ Open a closed index to make it available for search. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html
- Parameters
index – The name of the index
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘closed’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
master_timeout – Specify timeout for connection to master
timeout – Explicit operation timeout
wait_for_active_shards – Sets the number of active shards to wait for before the operation returns.
-
put_alias
(index, name, body=None, params=None)¶ Create an alias for a specific index/indices. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html
- Parameters
index – A comma-separated list of index names the alias should point to (supports wildcards); use _all to perform the operation on all indices.
name – The name of the alias to be created or updated
body – The settings for the alias, such as routing or filter
master_timeout – Specify timeout for connection to master
-
put_mapping
(body, doc_type=None, index=None, params=None)¶ Register specific mapping definition for a specific type. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html
- Parameters
body – The mapping definition
doc_type – The name of the document type
index – A comma-separated list of index names the mapping should be added to (supports wildcards); use _all or omit to add the mapping on all indices.
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
master_timeout – Specify timeout for connection to master
timeout – Explicit operation timeout
include_type_name – Specify whether requests and responses should include a type name (default: depends on Elasticsearch version).
-
put_settings
(body, index=None, params=None)¶ Change specific index level settings in real time. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html
- Parameters
body – The index settings to be updated
index – A comma-separated list of index names; use _all or empty string to perform the operation on all indices
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
flat_settings – Return settings in flat format (default: false)
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
master_timeout – Specify timeout for connection to master
preserve_existing – Whether to update existing settings. If set to true existing settings on an index remain unchanged, the default is false
timeout – Explicit operation timeout
-
put_template
(name, body, params=None)¶ Create an index template that will automatically be applied to new indices created. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html
- Parameters
name – The name of the template
body – The template definition
create – Whether the index template should only be added if new or can also replace an existing one, default False
flat_settings – Return settings in flat format (default: false)
master_timeout – Specify timeout for connection to master
order – The order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers)
timeout – Explicit operation timeout
include_type_name – Specify whether requests and responses should include a type name (default: depends on Elasticsearch version).
-
recovery
(index=None, params=None)¶ The indices recovery API provides insight into on-going shard recoveries. Recovery status may be reported for specific indices, or cluster-wide. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-recovery.html
- Parameters
index – A comma-separated list of index names; use _all or empty string to perform the operation on all indices
active_only – Display only those recoveries that are currently on- going, default False
detailed – Whether to display detailed information about shard recovery, default False
-
refresh
(index=None, params=None)¶ Explicitly refresh one or more index, making all operations performed since the last refresh available for search. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-refresh.html
- Parameters
index – A comma-separated list of index names; use _all or empty string to perform the operation on all indices
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
-
rollover
(alias, new_index=None, body=None, params=None)¶ The rollover index API rolls an alias over to a new index when the existing index is considered to be too large or too old.
The API accepts a single alias name and a list of conditions. The alias must point to a single index only. If the index satisfies the specified conditions then a new index is created and the alias is switched to point to the new alias. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-rollover-index.html
- Parameters
alias – The name of the alias to rollover
new_index – The name of the rollover index
body – The conditions that needs to be met for executing rollover
dry_run – If set to true the rollover action will only be validated but not actually performed even if a condition matches. The default is false
master_timeout – Specify timeout for connection to master
timeout – Explicit operation timeout
wait_for_active_shards – Set the number of active shards to wait for on the newly created rollover index before the operation returns.
include_type_name – Specify whether requests and responses should include a type name (default: depends on Elasticsearch version).
-
segments
(index=None, params=None)¶ Provide low level segments information that a Lucene index (shard level) is built with. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-segments.html
- Parameters
index – A comma-separated list of index names; use _all or empty string to perform the operation on all indices
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
operation_threading – TODO: ?
verbose – Includes detailed memory usage by Lucene., default False
-
shard_stores
(index=None, params=None)¶ Provides store information for shard copies of indices. Store information reports on which nodes shard copies exist, the shard copy version, indicating how recent they are, and any exceptions encountered while opening the shard index or from earlier engine failure. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-shards-stores.html
- Parameters
index – A comma-separated list of index names; use _all or empty string to perform the operation on all indices
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
operation_threading – TODO: ?
status – A comma-separated list of statuses used to filter on shards to get store information for, valid choices are: ‘green’, ‘yellow’, ‘red’, ‘all’
-
shrink
(index, target, body=None, params=None)¶ The shrink index API allows you to shrink an existing index into a new index with fewer primary shards. The number of primary shards in the target index must be a factor of the shards in the source index. For example an index with 8 primary shards can be shrunk into 4, 2 or 1 primary shards or an index with 15 primary shards can be shrunk into 5, 3 or 1. If the number of shards in the index is a prime number it can only be shrunk into a single primary shard. Before shrinking, a (primary or replica) copy of every shard in the index must be present on the same node. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-shrink-index.html
- Parameters
index – The name of the source index to shrink
target – The name of the target index to shrink into
body – The configuration for the target index (settings and aliases)
master_timeout – Specify timeout for connection to master
timeout – Explicit operation timeout
wait_for_active_shards – Set the number of active shards to wait for on the shrunken index before the operation returns.
-
split
(index, target, body=None, params=None)¶ http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-split-index.html
- Parameters
index – The name of the source index to split
target – The name of the target index to split into
body – The configuration for the target index (settings and aliases)
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)¶ Retrieve statistics on different operations happening on an index. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-stats.html
- Parameters
index – A comma-separated list of index names; use _all or empty string to perform the operation on all indices
metric – Limit the information returned the specific metrics.
completion_fields – A comma-separated list of fields for fielddata and suggest index metric (supports wildcards)
expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
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), default False
include_unloaded_segments – If set to true segment stats will include stats for segments that are not currently loaded into memory, default False
level – Return stats aggregated at cluster, index or shard level, default ‘indices’, valid choices are: ‘cluster’, ‘indices’, ‘shards’
types – A comma-separated list of document types for the indexing index metric
-
unfreeze
(index, params=None)¶ https://www.elastic.co/guide/en/elasticsearch/reference/current/frozen.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., default ‘closed’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
master_timeout – Specify timeout for connection to master
timeout – Explicit operation timeout
wait_for_active_shards – Sets the number of active shards to wait for before the operation returns.
-
update_aliases
(body, params=None)¶ Update specified aliases. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html
- Parameters
body – The definition of actions to perform
master_timeout – Specify timeout for connection to master
timeout – Request timeout
-
upgrade
(index=None, params=None)¶ Upgrade one or more indices to the latest format through an API. http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-upgrade.html
- Parameters
index – A comma-separated list of index names; use _all or empty string to perform the operation on all indices
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
only_ancient_segments – If true, only ancient (an older Lucene major release) segments will be upgraded
wait_for_completion – Specify whether the request should block until the all segments are upgraded (default: false)
-
validate_query
(index=None, doc_type=None, body=None, params=None)¶ Validate a potentially expensive query without executing it. http://www.elastic.co/guide/en/elasticsearch/reference/current/search-validate.html
- Parameters
index – A comma-separated list of index names to restrict the operation; use _all or empty string to perform the operation on all indices
doc_type – A comma-separated list of document types to restrict the operation; leave empty to perform the operation on all types
body – The query definition specified with the Query DSL
all_shards – Execute validation on all shards instead of one random shard per index
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
analyze_wildcard – Specify whether wildcard and prefix queries should be analyzed (default: false)
analyzer – The analyzer to use for the query string
default_operator – The default operator for query string query (AND or OR), default ‘OR’, valid choices are: ‘AND’, ‘OR’
df – The field to use as default where no field prefix is given in the query string
expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
explain – Return detailed information about the error
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
lenient – Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
operation_threading – TODO: ?
q – Query in the Lucene query string syntax
rewrite – Provide a more detailed explanation showing the actual Lucene query that will be executed.
-
Ingest¶
-
class
elasticsearch.client.
IngestClient
(client)¶ -
delete_pipeline
(id, params=None)¶ https://www.elastic.co/guide/en/elasticsearch/plugins/current/ingest.html
- Parameters
id – Pipeline ID
master_timeout – Explicit operation timeout for connection to master node
timeout – Explicit operation timeout
-
get_pipeline
(id=None, params=None)¶ https://www.elastic.co/guide/en/elasticsearch/plugins/current/ingest.html
- Parameters
id – Comma separated list of pipeline ids. Wildcards supported
master_timeout – Explicit operation timeout for connection to master node
-
processor_grok
(params=None)¶
-
put_pipeline
(id, body, params=None)¶ https://www.elastic.co/guide/en/elasticsearch/plugins/current/ingest.html
- Parameters
id – Pipeline ID
body – The ingest definition
master_timeout – Explicit operation timeout for connection to master node
timeout – Explicit operation timeout
-
simulate
(body, id=None, params=None)¶ https://www.elastic.co/guide/en/elasticsearch/plugins/current/ingest.html
- Parameters
body – The simulate definition
id – Pipeline ID
verbose – Verbose mode. Display data output for each processor in executed pipeline, default False
-
Cluster¶
-
class
elasticsearch.client.
ClusterClient
(client)¶ -
allocation_explain
(body=None, params=None)¶ http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-allocation-explain.html
- Parameters
body – The index, shard, and primary flag to explain. Empty means ‘explain the first unassigned shard’
include_disk_info – Return information about disk usage and shard sizes (default: false)
include_yes_decisions – Return ‘YES’ decisions in explanation (default: false)
-
get_settings
(params=None)¶ Get cluster settings. http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-update-settings.html
- Parameters
flat_settings – Return settings in flat format (default: false)
include_defaults – Whether to return all default clusters setting., default False
master_timeout – Explicit operation timeout for connection to master node
timeout – Explicit operation timeout
-
health
(index=None, params=None)¶ Get a very simple status on the health of the cluster. http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html
- Parameters
index – Limit the information returned to a specific index
expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘all’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
level – Specify the level of detail for returned information, default ‘cluster’, valid choices are: ‘cluster’, ‘indices’, ‘shards’
local – Return local information, do not retrieve the state from master node (default: false)
master_timeout – Explicit operation timeout for connection to master node
timeout – Explicit operation timeout
wait_for_active_shards – Wait until the specified number of shards is active
wait_for_events – Wait until all currently queued events with the given priority are processed, valid choices are: ‘immediate’, ‘urgent’, ‘high’, ‘normal’, ‘low’, ‘languid’
wait_for_no_relocating_shards – Whether to wait until there are no relocating shards in the cluster
wait_for_nodes – Wait until the specified number of nodes is available
wait_for_status – Wait until cluster is in a specific state, default None, valid choices are: ‘green’, ‘yellow’, ‘red’
-
pending_tasks
(params=None)¶ The pending cluster tasks API returns a list of any cluster-level changes (e.g. create index, update mapping, allocate or fail shard) which have not yet been executed. http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-pending.html
- Parameters
local – Return local information, do not retrieve the state from master node (default: false)
master_timeout – Specify timeout for connection to master
-
put_settings
(body=None, params=None)¶ Update cluster wide specific settings. http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-update-settings.html
- Parameters
body – The settings to be updated. Can be either transient or persistent (survives cluster restart).
flat_settings – Return settings in flat format (default: false)
master_timeout – Explicit operation timeout for connection to master node
timeout – Explicit operation timeout
-
remote_info
(params=None)¶ http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-remote-info.html
-
reroute
(body=None, params=None)¶ Explicitly execute a cluster reroute allocation command including specific commands. http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-reroute.html
- Parameters
body – The definition of commands to perform (move, cancel, allocate)
dry_run – Simulate the operation only and return the resulting state
explain – Return an explanation of why the commands can or cannot be executed
master_timeout – Explicit operation timeout for connection to master node
metric – Limit the information returned to the specified metrics. Defaults to all but metadata, valid choices are: ‘_all’, ‘blocks’, ‘metadata’, ‘nodes’, ‘routing_table’, ‘master_node’, ‘version’
retry_failed – Retries allocation of shards that are blocked due to too many subsequent allocation failures
timeout – Explicit operation timeout
-
state
(metric=None, index=None, params=None)¶ Get a comprehensive state information of the whole cluster. http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-state.html
- Parameters
metric – Limit the information returned to the specified metrics
index – A comma-separated list of index names; use _all or empty string to perform the operation on all indices
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
flat_settings – Return settings in flat format (default: false)
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
local – Return local information, do not retrieve the state from master node (default: false)
master_timeout – Specify timeout for connection to master
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)¶ The Cluster Stats API allows to retrieve statistics from a cluster wide perspective. The API returns basic index metrics and information about the current nodes that form the cluster. http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-stats.html
- Parameters
node_id – A comma-separated list of node IDs or names to limit the returned information; use _local to return information from the node you’re connecting to, _master to return information from the currently-elected master node or leave empty to get information from all nodes
flat_settings – Return settings in flat format (default: false)
timeout – Explicit operation timeout
-
Nodes¶
-
class
elasticsearch.client.
NodesClient
(client)¶ -
hot_threads
(node_id=None, params=None)¶ An API allowing to get the current hot threads on each node in the cluster. https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-hot-threads.html
- Parameters
node_id – A comma-separated list of node IDs or names to limit the returned information; use _local to return information from the node you’re connecting to, leave empty to get information from all nodes
type – The type to sample (default: cpu), valid choices are: ‘cpu’, ‘wait’, ‘block’
ignore_idle_threads – Don’t show threads that are in known-idle places, such as waiting on a socket select or pulling from an empty task queue (default: true)
interval – The interval for the second sampling of threads
snapshots – Number of samples of thread stacktrace (default: 10)
threads – Specify the number of threads to provide information for (default: 3)
timeout – Explicit operation timeout
-
info
(node_id=None, metric=None, params=None)¶ The cluster nodes info API allows to retrieve one or more (or all) of the cluster nodes information. https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-info.html
- Parameters
node_id – A comma-separated list of node IDs or names to limit the returned information; use _local to return information from the node you’re connecting to, leave empty to get information from all nodes
metric – A comma-separated list of metrics you wish returned. Leave empty to return all.
flat_settings – Return settings in flat format (default: false)
timeout – Explicit operation timeout
-
reload_secure_settings
(node_id=None, params=None)¶ Reload any settings that have been marked as “reloadable” https://www.elastic.co/guide/en/elasticsearch/reference/current/secure-settings.html#reloadable-secure-settings
- Parameters
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)¶ The cluster nodes stats API allows to retrieve one or more (or all) of the cluster nodes statistics. https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-stats.html
- Parameters
node_id – A comma-separated list of node IDs or names to limit the returned information; use _local to return information from the node you’re connecting to, leave empty to get information from all nodes
metric – Limit the information returned to the specified metrics
index_metric – Limit the information returned for indices metric to the specific index metrics. Isn’t used if indices (or all) metric isn’t specified.
completion_fields – A comma-separated list of fields for fielddata and suggest index metric (supports wildcards)
fielddata_fields – A comma-separated list of fields for fielddata index metric (supports wildcards)
fields – A comma-separated list of fields for fielddata and completion index metric (supports wildcards)
groups – A comma-separated list of search groups for search index metric
include_segment_file_sizes – Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested), default False
level – Return indices stats aggregated at index, node or shard level, default ‘node’, valid choices are: ‘indices’, ‘node’, ‘shards’
timeout – Explicit operation timeout
types – A comma-separated list of document types for the indexing index metric
-
usage
(node_id=None, metric=None, params=None)¶ The cluster nodes usage API allows to retrieve information on the usage of features for each node. http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-usage.html
- Parameters
node_id – A comma-separated list of node IDs or names to limit the returned information; use _local to return information from the node you’re connecting to, leave empty to get information from all nodes
metric – Limit the information returned to the specified metrics
human – Whether to return time and byte values in human-readable format., default False
timeout – Explicit operation timeout
-
Cat¶
-
class
elasticsearch.client.
CatClient
(client)¶ -
aliases
(name=None, params=None)¶ https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-alias.html
- Parameters
name – A comma-separated list of alias names to return
format – a short version of the Accept header, e.g. json, yaml
h – Comma-separated list of column names to display
help – Return help information, default False
local – Return local information, do not retrieve the state from master node (default: false)
master_timeout – Explicit operation timeout for connection to master node
s – Comma-separated list of column names or column aliases to sort by
v – Verbose mode. Display column headers, default False
-
allocation
(node_id=None, params=None)¶ Allocation provides a snapshot of how shards have located around the cluster and the state of disk usage. https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-allocation.html
- Parameters
node_id – A comma-separated list of node IDs or names to limit the returned information
bytes – The unit in which to display byte values, valid choices are: ‘b’, ‘k’, ‘kb’, ‘m’, ‘mb’, ‘g’, ‘gb’, ‘t’, ‘tb’, ‘p’, ‘pb’
format – a short version of the Accept header, e.g. json, yaml
h – Comma-separated list of column names to display
help – Return help information, default False
local – Return local information, do not retrieve the state from master node (default: false)
master_timeout – Explicit operation timeout for connection to master node
s – Comma-separated list of column names or column aliases to sort by
v – Verbose mode. Display column headers, default False
-
count
(index=None, params=None)¶ Count provides quick access to the document count of the entire cluster, or individual indices. https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-count.html
- Parameters
index – A comma-separated list of index names to limit the returned information
format – a short version of the Accept header, e.g. json, yaml
h – Comma-separated list of column names to display
help – Return help information, default False
local – Return local information, do not retrieve the state from master node (default: false)
master_timeout – Explicit operation timeout for connection to master node
s – Comma-separated list of column names or column aliases to sort by
v – Verbose mode. Display column headers, default False
-
fielddata
(fields=None, params=None)¶ Shows information about currently loaded fielddata on a per-node basis. https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-fielddata.html
- Parameters
fields – A comma-separated list of fields to return the fielddata size
bytes – The unit in which to display byte values, valid choices are: ‘b’, ‘k’, ‘kb’, ‘m’, ‘mb’, ‘g’, ‘gb’, ‘t’, ‘tb’, ‘p’, ‘pb’
format – a short version of the Accept header, e.g. json, yaml
h – Comma-separated list of column names to display
help – Return help information, default False
local – Return local information, do not retrieve the state from master node (default: false)
master_timeout – Explicit operation timeout for connection to master node
s – Comma-separated list of column names or column aliases to sort by
v – Verbose mode. Display column headers, default False
-
health
(params=None)¶ health is a terse, one-line representation of the same information from
health()
API https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-health.html- Parameters
format – a short version of the Accept header, e.g. json, yaml
h – Comma-separated list of column names to display
help – Return help information, default False
local – Return local information, do not retrieve the state from master node (default: false)
master_timeout – Explicit operation timeout for connection to master node
s – Comma-separated list of column names or column aliases to sort by
ts – Set to false to disable timestamping, default True
v – Verbose mode. Display column headers, default False
-
help
(params=None)¶ A simple help for the cat api. https://www.elastic.co/guide/en/elasticsearch/reference/current/cat.html
- Parameters
help – Return help information, default False
s – Comma-separated list of column names or column aliases to sort by
-
indices
(index=None, params=None)¶ The indices command provides a cross-section of each index. https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-indices.html
- Parameters
index – A comma-separated list of index names to limit the returned information
bytes – The unit in which to display byte values, valid choices are: ‘b’, ‘k’, ‘m’, ‘g’
format – a short version of the Accept header, e.g. json, yaml
h – Comma-separated list of column names to display
health – A health status (“green”, “yellow”, or “red” to filter only indices matching the specified health status, default None, valid choices are: ‘green’, ‘yellow’, ‘red’
help – Return help information, default False
local – Return local information, do not retrieve the state from master node (default: false)
master_timeout – Explicit operation timeout for connection to master node
pri – Set to true to return stats only for primary shards, default False
s – Comma-separated list of column names or column aliases to sort by
v – Verbose mode. Display column headers, default False
-
master
(params=None)¶ Displays the master’s node ID, bound IP address, and node name. https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-master.html
- Parameters
format – a short version of the Accept header, e.g. json, yaml
h – Comma-separated list of column names to display
help – Return help information, default False
local – Return local information, do not retrieve the state from master node (default: false)
master_timeout – Explicit operation timeout for connection to master node
s – Comma-separated list of column names or column aliases to sort by
v – Verbose mode. Display column headers, default False
-
nodeattrs
(params=None)¶ https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-nodeattrs.html
- Parameters
format – a short version of the Accept header, e.g. json, yaml
h – Comma-separated list of column names to display
help – Return help information, default False
local – Return local information, do not retrieve the state from master node (default: false)
master_timeout – Explicit operation timeout for connection to master node
s – Comma-separated list of column names or column aliases to sort by
v – Verbose mode. Display column headers, default False
-
nodes
(params=None)¶ The nodes command shows the cluster topology. https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-nodes.html
- Parameters
format – a short version of the Accept header, e.g. json, yaml
full_id – Return the full node ID instead of the shortened version (default: false)
h – Comma-separated list of column names to display
help – Return help information, default False
local – Return local information, do not retrieve the state from master node (default: false)
master_timeout – Explicit operation timeout for connection to master node
s – Comma-separated list of column names or column aliases to sort by
v – Verbose mode. Display column headers, default False
-
pending_tasks
(params=None)¶ pending_tasks provides the same information as the
pending_tasks()
API in a convenient tabular format. https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-pending-tasks.html- Parameters
format – a short version of the Accept header, e.g. json, yaml
h – Comma-separated list of column names to display
help – Return help information, default False
local – Return local information, do not retrieve the state from master node (default: false)
master_timeout – Explicit operation timeout for connection to master node
s – Comma-separated list of column names or column aliases to sort by
v – Verbose mode. Display column headers, default False
-
plugins
(params=None)¶ https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-plugins.html
- Parameters
format – a short version of the Accept header, e.g. json, yaml
h – Comma-separated list of column names to display
help – Return help information, default False
local – Return local information, do not retrieve the state from master node (default: false)
master_timeout – Explicit operation timeout for connection to master node
s – Comma-separated list of column names or column aliases to sort by
v – Verbose mode. Display column headers, default False
-
recovery
(index=None, params=None)¶ recovery is a view of shard replication. https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-recovery.html
- Parameters
index – A comma-separated list of index names to limit the returned information
bytes – The unit in which to display byte values, valid choices are: ‘b’, ‘k’, ‘kb’, ‘m’, ‘mb’, ‘g’, ‘gb’, ‘t’, ‘tb’, ‘p’, ‘pb’
format – a short version of the Accept header, e.g. json, yaml
h – Comma-separated list of column names to display
help – Return help information, default False
master_timeout – Explicit operation timeout for connection to master node
s – Comma-separated list of column names or column aliases to sort by
v – Verbose mode. Display column headers, default False
-
repositories
(params=None)¶ https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-repositories.html
- Parameters
format – a short version of the Accept header, e.g. json, yaml
h – Comma-separated list of column names to display
help – Return help information, default False
local – Return local information, do not retrieve the state from master node, default False
master_timeout – Explicit operation timeout for connection to master node
s – Comma-separated list of column names or column aliases to sort by
v – Verbose mode. Display column headers, default False
-
segments
(index=None, params=None)¶ The segments command is the detailed view of Lucene segments per index. https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-segments.html
- Parameters
index – A comma-separated list of index names to limit the returned information
bytes – The unit in which to display byte values, valid choices are: ‘b’, ‘k’, ‘kb’, ‘m’, ‘mb’, ‘g’, ‘gb’, ‘t’, ‘tb’, ‘p’, ‘pb’
format – a short version of the Accept header, e.g. json, yaml
h – Comma-separated list of column names to display
help – Return help information, default False
s – Comma-separated list of column names or column aliases to sort by
v – Verbose mode. Display column headers, default False
-
shards
(index=None, params=None)¶ The shards command is the detailed view of what nodes contain which shards. https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-shards.html
- Parameters
index – A comma-separated list of index names to limit the returned information
bytes – The unit in which to display byte values, valid choices are: ‘b’, ‘k’, ‘kb’, ‘m’, ‘mb’, ‘g’, ‘gb’, ‘t’, ‘tb’, ‘p’, ‘pb’
format – a short version of the Accept header, e.g. json, yaml
h – Comma-separated list of column names to display
help – Return help information, default False
local – Return local information, do not retrieve the state from master node (default: false)
master_timeout – Explicit operation timeout for connection to master node
s – Comma-separated list of column names or column aliases to sort by
v – Verbose mode. Display column headers, default False
-
snapshots
(repository, params=None)¶ https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-snapshots.html
- Parameters
repository – Name of repository from which to fetch the snapshot information
format – a short version of the Accept header, e.g. json, yaml
h – Comma-separated list of column names to display
help – Return help information, default False
ignore_unavailable – Set to true to ignore unavailable snapshots, default False
master_timeout – Explicit operation timeout for connection to master node
s – Comma-separated list of column names or column aliases to sort by
v – Verbose mode. Display column headers, default False
-
tasks
(params=None)¶ https://www.elastic.co/guide/en/elasticsearch/reference/current/tasks.html
- Parameters
actions – A comma-separated list of actions that should be returned. Leave empty to return all.
detailed – Return detailed task information (default: false)
format – a short version of the Accept header, e.g. json, yaml
h – Comma-separated list of column names to display
help – Return help information, default False
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 (used for older version of Elasticsearch)
node_id – A comma-separated list of node IDs or names to limit the returned information; use _local to return information from the node you’re connecting to, leave empty to get information from all nodes
parent_task_id – Return tasks with specified parent task id. Set to -1 to return all.
s – Comma-separated list of column names or column aliases to sort by
v – Verbose mode. Display column headers, default False
-
templates
(name=None, params=None)¶ https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-templates.html
- Parameters
name – A pattern that returned template names must match
format – a short version of the Accept header, e.g. json, yaml
h – Comma-separated list of column names to display
help – Return help information, default False
local – Return local information, do not retrieve the state from master node (default: false)
master_timeout – Explicit operation timeout for connection to master node
s – Comma-separated list of column names or column aliases to sort by
v – Verbose mode. Display column headers, default False
-
thread_pool
(thread_pool_patterns=None, params=None)¶ Get information about thread pools. https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-thread-pool.html
- Parameters
thread_pool_patterns – A comma-separated list of regular-expressions to filter the thread pools in the output
format – a short version of the Accept header, e.g. json, yaml
h – Comma-separated list of column names to display
help – Return help information, default False
local – Return local information, do not retrieve the state from master node (default: false)
master_timeout – Explicit operation timeout for connection to master node
s – Comma-separated list of column names or column aliases to sort by
size – The multiplier in which to display values, valid choices are: ‘’, ‘k’, ‘m’, ‘g’, ‘t’, ‘p’
v – Verbose mode. Display column headers, default False
-
Snapshot¶
-
class
elasticsearch.client.
SnapshotClient
(client)¶ -
create
(repository, snapshot, body=None, params=None)¶ Create a snapshot in repository http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html
- Parameters
repository – A repository name
snapshot – A snapshot name
body – The snapshot definition
master_timeout – Explicit operation timeout for connection to master node
wait_for_completion – Should this request wait until the operation has completed before returning, default False
-
create_repository
(repository, body, params=None)¶ Registers a shared file system repository. http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html
- Parameters
repository – A repository name
body – The repository definition
master_timeout – Explicit operation timeout for connection to master node
timeout – Explicit operation timeout
verify – Whether to verify the repository after creation
-
delete
(repository, snapshot, params=None)¶ Deletes a snapshot from a repository. http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html
- Parameters
repository – A repository name
snapshot – A snapshot name
master_timeout – Explicit operation timeout for connection to master node
-
delete_repository
(repository, params=None)¶ Removes a shared file system repository. http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html
- Parameters
repository – A comma-separated list of repository names
master_timeout – Explicit operation timeout for connection to master node
timeout – Explicit operation timeout
-
get
(repository, snapshot, params=None)¶ Retrieve information about a snapshot. http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html
- Parameters
repository – A repository name
snapshot – A comma-separated list of snapshot names
ignore_unavailable – Whether to ignore unavailable snapshots, defaults to false which means a NotFoundError snapshot_missing_exception is thrown
master_timeout – Explicit operation timeout for connection to master node
verbose – Whether to show verbose snapshot info or only show the basic info found in the repository index blob
-
get_repository
(repository=None, params=None)¶ Return information about registered repositories. http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html
- Parameters
repository – A comma-separated list of repository names
local – Return local information, do not retrieve the state from master node (default: false)
master_timeout – Explicit operation timeout for connection to master node
-
restore
(repository, snapshot, body=None, params=None)¶ Restore a snapshot. http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html
- Parameters
repository – A repository name
snapshot – A snapshot name
body – Details of what to restore
master_timeout – Explicit operation timeout for connection to master node
wait_for_completion – Should this request wait until the operation has completed before returning, default False
-
status
(repository=None, snapshot=None, params=None)¶ Return information about all currently running snapshots. By specifying a repository name, it’s possible to limit the results to a particular repository. http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html
- Parameters
repository – A repository name
snapshot – A comma-separated list of snapshot names
ignore_unavailable – Whether to ignore unavailable snapshots, defaults to false which means a NotFoundError snapshot_missing_exception is thrown
master_timeout – Explicit operation timeout for connection to master node
-
verify_repository
(repository, params=None)¶ Returns a list of nodes where repository was successfully verified or an error message if verification process failed. http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html
- Parameters
repository – A repository name
master_timeout – Explicit operation timeout for connection to master node
timeout – Explicit operation timeout
-
Tasks¶
-
class
elasticsearch.client.
TasksClient
(client)¶ -
cancel
(task_id=None, params=None)¶ http://www.elastic.co/guide/en/elasticsearch/reference/current/tasks.html
- Parameters
task_id – Cancel the task with specified task id (node_id:task_number)
actions – A comma-separated list of actions that should be cancelled. Leave empty to cancel all.
nodes – A comma-separated list of node IDs or names to limit the returned information; use _local to return information from the node you’re connecting to, leave empty to get information from all nodes
parent_task_id – Cancel tasks with specified parent task id (node_id:task_number). Set to -1 to cancel all.
-
get
(task_id=None, params=None)¶ Retrieve information for a particular task. http://www.elastic.co/guide/en/elasticsearch/reference/current/tasks.html
- Parameters
task_id – Return the task with specified id (node_id:task_number)
wait_for_completion – Wait for the matching tasks to complete (default: false)
timeout – Maximum waiting time for wait_for_completion
-
list
(params=None)¶ http://www.elastic.co/guide/en/elasticsearch/reference/current/tasks.html
- Parameters
actions – A comma-separated list of actions that should be returned. Leave empty to return all.
detailed – Return detailed task information (default: false)
group_by – Group tasks by nodes or parent/child relationships, default ‘nodes’, valid choices are: ‘nodes’, ‘parents’
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.
wait_for_completion – Wait for the matching tasks to complete (default: false)
timeout – Maximum waiting time for wait_for_completion
-