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 (off by default) verify_certs=True, # provide a path to CA certs on disk ca_certs='/path/to/CA_certs' )
SSL client authentication is supported (see
Urllib3HttpConnection
for detailed description of the options):es = Elasticsearch( ['localhost:443', 'other_host:443'], # turn on SSL use_ssl=True, # make sure we verify SSL certificates (off by default) verify_certs=True, # provide a path to CA certs on disk ca_certs='/path/to/CA_certs', # PEM formatted SSL client certificate client_cert='/path/to/clientcert.pem', # PEM formatted SSL client key client_key='/path/to/clientkey.pem' )
Alternatively you can use RFC-1738 formatted URLs, as long as they are not in conflict with other options:
es = Elasticsearch( [ 'http://user:secret@localhost:9200/', 'https://user:secret@other_host:443/production' ], verify_certs=True )
- Parameters
hosts – list of nodes we should connect to. Node should be a dictionary ({“host”: “localhost”, “port”: 9200}), the entire dictionary will be passed to the
Connection
class as kwargs, or a string in the format 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, index=None, doc_type=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
doc_type – Default document type for items which don’t provide one
_source – True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub- request
_source_exclude – Default list of fields to exclude from the returned _source field, can be overridden on each sub-request
_source_include – Default list of fields to extract and return from the _source field, can be overridden on each sub-request
fields – Default comma-separated list of fields to return in the response for updates, can be overridden on each sub-request
pipeline – The pipeline id to preprocess incoming documents with
refresh – If true then refresh the effected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false (the default) then do nothing with refreshes., valid choices are: ‘true’, ‘false’, ‘wait_for’
routing – Specific routing value
timeout – Explicit operation timeout
wait_for_active_shards – Sets the number of shard copies that must be active before proceeding with the bulk operation. Defaults to 1, meaning the primary shard only. Set to all for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
- clear_scroll(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(index=None, doc_type=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 comma-separated list of indices to restrict the results
doc_type – A comma-separated list of types to restrict the results
body – A query to restrict the results specified with the Query DSL (optional)
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
analyze_wildcard – Specify whether wildcard and prefix queries should be analyzed (default: false)
analyzer – The analyzer to use for the query string
default_operator – The default operator for query string query (AND or OR), default ‘OR’, valid choices are: ‘AND’, ‘OR’
df – The field to use as default where no field prefix is given in the query string
expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
lenient – Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
lowercase_expanded_terms – Specify whether query terms should be lowercased
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
- count_percolate(index, doc_type, id=None, body=None, params=None)¶
The percolator allows to register queries against an index, and then send percolate requests which include a doc, and getting back the queries that match on that doc out of the set of registered queries. http://www.elastic.co/guide/en/elasticsearch/reference/current/search-percolate.html
- Parameters
index – The index of the document being count percolated.
doc_type – The type of the document being count percolated.
id – Substitute the document in the request body with a document that is known by the specified id. On top of the id, the index and type parameter will be used to retrieve the document from within the cluster.
body – The count percolator request definition using the percolate DSL
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)
percolate_index – The index to count percolate the document into. Defaults to index.
percolate_type – The type to count percolate document into. Defaults to type.
preference – Specify the node or shard the operation should be performed on (default: random)
routing – A comma-separated list of specific routing values
version – Explicit version number for concurrency control
version_type – Specific version type, valid choices are: ‘internal’, ‘external’, ‘external_gte’, ‘force’
- create(index, doc_type, id, body, 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
doc_type – The type of the document
id – Document ID
body – The document
parent – ID of the parent document
pipeline – The pipeline id to preprocess incoming documents with
refresh – If true then refresh the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false (the default) then do nothing with refreshes., valid choices are: u’true’, u’false’, u’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: u’internal’, u’external’, u’external_gte’, u’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, doc_type, id, 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
doc_type – The type of the document
id – The document ID
parent – ID of parent document
refresh – If true then refresh the effected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false (the default) then do nothing with refreshes., valid choices are: ‘true’, ‘false’, ‘wait_for’
routing – Specific routing value
timeout – Explicit operation timeout
version – Explicit version number for concurrency control
version_type – Specific version type, valid choices are: ‘internal’, ‘external’, ‘external_gte’, ‘force’
wait_for_active_shards – Sets the number of shard copies that must be active before proceeding with the delete operation. Defaults to 1, meaning the primary shard only. Set to all for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
- delete_by_query(index, body, doc_type=None, 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 comma-separated list of index names to search; use _all or empty string to perform the operation on all indices
body – The search definition using the Query DSL
doc_type – A comma-separated list of document types to search; leave empty to perform the operation on all types
_source – True or false to return the _source field or not, or a list of fields to return
_source_exclude – A list of fields to exclude from the returned _source field
_source_include – A list of fields to extract and return from the _source field
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
analyze_wildcard – Specify whether wildcard and prefix queries should be analyzed (default: false)
analyzer – The analyzer to use for the query string
conflicts – What to do when the delete-by-query hits version conflicts?, default ‘abort’, valid choices are: ‘abort’, ‘proceed’
default_operator – The default operator for query string query (AND or OR), default ‘OR’, valid choices are: ‘AND’, ‘OR’
df – The field to use as default where no field prefix is given in the query string
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
lowercase_expanded_terms – Specify whether query terms should be lowercased
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 set 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)
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 – Time each individual bulk request should wait for shards that are unavailable., default ‘1m’
track_scores – Whether to calculate and return scores even if they are not used for sorting
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 False
- delete_script(lang, id, params=None)¶
Remove a stored script from elasticsearch. http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html
- Parameters
lang – Script language
id – Script ID
- delete_template(id, params=None)¶
Delete a search template. http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html
- Parameters
id – Template ID
- exists(index, doc_type, id, 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
doc_type – The type of the document (use _all to fetch the first document matching the ID across all types)
id – The document ID
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
- explain(index, doc_type, id, 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
doc_type – The type of the document
id – The document ID
body – The query definition using the Query DSL
_source – True or false to return the _source field or not, or a list of fields to return
_source_exclude – A list of fields to exclude from the returned _source field
_source_include – A list of fields to extract and return from the _source field
analyze_wildcard – Specify whether wildcards and prefix queries in the query string query should be analyzed (default: false)
analyzer – The analyzer for the query string query
default_operator – The default operator for query string query (AND or OR), default ‘OR’, valid choices are: ‘AND’, ‘OR’
df – The default field for query string query (default: _all)
lenient – Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
lowercase_expanded_terms – Specify whether query terms should be lowercased
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_stats(index=None, body=None, params=None)¶
The field stats api allows one to find statistical properties of a field without executing a search, but looking up measurements that are natively available in the Lucene index. http://www.elastic.co/guide/en/elasticsearch/reference/current/search-field-stats.html
- Parameters
index – A comma-separated list of index names; use _all or empty string to perform the operation on all indices
body – Field json objects containing the name and optionally a range to filter out indices result, that have results outside the defined bounds
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 fields for to get field statistics for (min value, max value, and more)
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
level – Defines if field stats should be returned on a per index level or on a cluster wide level, default ‘cluster’, valid choices are: ‘indices’, ‘cluster’
- get(index, id, doc_type='_all', 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
doc_type – The type of the document (use _all to fetch the first document matching the ID across all types)
id – The document ID
_source – True or false to return the _source field or not, or a list of fields to return
_source_exclude – A list of fields to exclude from the returned _source field
_source_include – A list of fields to extract and return from the _source field
parent – The ID of the parent document
preference – Specify the node or shard the operation should be performed on (default: random)
realtime – Specify whether to perform the operation in realtime or search mode
refresh – Refresh the shard containing the document before performing the operation
routing – Specific routing value
stored_fields – A comma-separated list of stored fields to return in the response
version – Explicit version number for concurrency control
version_type – Specific version type, valid choices are: ‘internal’, ‘external’, ‘external_gte’, ‘force’
- get_script(lang, id, params=None)¶
Retrieve a script from the API. http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html
- Parameters
lang – Script language
id – Script ID
- get_source(index, doc_type, id, 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
doc_type – The type of the document; use _all to fetch the first document matching the ID across all types
id – The document ID
_source – True or false to return the _source field or not, or a list of fields to return
_source_exclude – A list of fields to exclude from the returned _source field
_source_include – A list of fields to extract and return from the _source field
parent – The ID of the parent document
preference – Specify the node or shard the operation should be performed on (default: random)
realtime – Specify whether to perform the operation in realtime or search mode
refresh – Refresh the shard containing the document before performing the operation
routing – Specific routing value
version – Explicit version number for concurrency control
version_type – Specific version type, valid choices are: ‘internal’, ‘external’, ‘external_gte’, ‘force’
- get_template(id, params=None)¶
Retrieve a search template. http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html
- Parameters
id – Template ID
- index(index, doc_type, body, 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
doc_type – The type of the document
body – The document
id – Document ID
op_type – Explicit operation type, default ‘index’, valid choices are: ‘index’, ‘create’
parent – ID of the parent document
pipeline – The pipeline id to preprocess incoming documents with
refresh – If true then refresh the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false (the default) then do nothing with refreshes., valid choices are: u’true’, u’false’, u’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, index=None, doc_type=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
doc_type – The type of the document
_source – True or false to return the _source field or not, or a list of fields to return
_source_exclude – A list of fields to exclude from the returned _source field
_source_include – A list of fields to extract and return from the _source field
preference – Specify the node or shard the operation should be performed on (default: random)
realtime – Specify whether to perform the operation in realtime or search mode
refresh – Refresh the shard containing the document before performing the operation
stored_fields – A comma-separated list of stored fields to return in the response
- mpercolate(body, index=None, doc_type=None, params=None)¶
The percolator allows to register queries against an index, and then send percolate requests which include a doc, and getting back the queries that match on that doc out of the set of registered queries. http://www.elastic.co/guide/en/elasticsearch/reference/current/search-percolate.html
- Parameters
body – The percolate request definitions (header & body pair), separated by newlines
index – The index of the document being count percolated to use as default
doc_type – The type of the document being percolated to use as default.
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)
- msearch(body, index=None, doc_type=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 comma-separated list of index names to use as default
doc_type – A comma-separated list of document types to use as default
max_concurrent_searches – Controls the maximum number of concurrent searches the multi search api will execute
search_type – Search operation type, valid choices are: ‘query_then_fetch’, ‘query_and_fetch’, ‘dfs_query_then_fetch’, ‘dfs_query_and_fetch’
- msearch_template(body, index=None, doc_type=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 comma-separated list of index names to use as default
doc_type – A comma-separated list of document types to use as default
search_type – Search operation type, valid choices are: ‘query_then_fetch’, ‘query_and_fetch’, ‘dfs_query_then_fetch’, ‘dfs_query_and_fetch’
- mtermvectors(index=None, doc_type=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.
doc_type – The type of the document.
body – Define ids, documents, parameters or a list of parameters per document here. You must at least provide a list of document ids. See documentation.
field_statistics – Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified in body “params” or “docs”., default True
fields – A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body “params” or “docs”.
ids – A comma-separated list of documents ids. You must define ids as parameter or set “ids” or “docs” in the request body
offsets – Specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body “params” or “docs”., default True
parent – Parent id of documents. Applies to all returned documents unless otherwise specified in body “params” or “docs”.
payloads – Specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body “params” or “docs”., default True
positions – Specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body “params” or “docs”., default True
preference – Specify the node or shard the operation should be performed on (default: random) .Applies to all returned documents unless otherwise specified in body “params” or “docs”.
realtime – Specifies if requests are real-time as opposed to near- real-time (default: true).
routing – Specific routing value. Applies to all returned documents unless otherwise specified in body “params” or “docs”.
term_statistics – Specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body “params” or “docs”., default False
version – Explicit version number for concurrency control
version_type – Specific version type, valid choices are: ‘internal’, ‘external’, ‘external_gte’, ‘force’
- percolate(index, doc_type, id=None, body=None, params=None)¶
The percolator allows to register queries against an index, and then send percolate requests which include a doc, and getting back the queries that match on that doc out of the set of registered queries. http://www.elastic.co/guide/en/elasticsearch/reference/current/search-percolate.html
- Parameters
index – The index of the document being percolated.
doc_type – The type of the document being percolated.
id – Substitute the document in the request body with a document that is known by the specified id. On top of the id, the index and type parameter will be used to retrieve the document from within the cluster.
body – The percolator request definition using the percolate DSL
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)
percolate_format – Return an array of matching query IDs instead of objects, valid choices are: ‘ids’
percolate_index – The index to percolate the document into. Defaults to index.
percolate_preference – Which shard to prefer when executing the percolate request.
percolate_routing – The routing value to use when percolating the existing document.
percolate_type – The type to percolate document into. Defaults to type.
preference – Specify the node or shard the operation should be performed on (default: random)
routing – A comma-separated list of specific routing values
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(lang, id, body, params=None)¶
Create a script in given language with specified ID. http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html
- Parameters
lang – Script language
id – Script ID
body – The document
- put_template(id, body, params=None)¶
Create a search template. http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html
- Parameters
id – Template ID
body – The document
- 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 set no throttle as does “unlimited” which is the only non-float this accepts., default 0
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 False
- 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
- scroll(scroll_id=None, body=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
- search(index=None, doc_type=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 comma-separated list of index names to search; use _all or empty string to perform the operation on all indices
doc_type – A comma-separated list of document types to search; leave empty to perform the operation on all types
body – The search definition using the Query DSL
_source – True or false to return the _source field or not, or a list of fields to return
_source_exclude – A list of fields to exclude from the returned _source field
_source_include – A list of fields to extract and return from the _source field
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
analyze_wildcard – Specify whether wildcard and prefix queries should be analyzed (default: false)
analyzer – The analyzer to use for the query string
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
fielddata_fields – A comma-separated list of fields to return as the docvalue representation of a field for each 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
lowercase_expanded_terms – Specify whether query terms should be lowercased
preference – Specify the node or shard the operation should be performed on (default: random)
q – Query in the Lucene query string syntax
request_cache – Specify if request cache should be used for this request or not, defaults to index level setting
routing – A comma-separated list of specific routing values
scroll – Specify how long a consistent view of the index should be maintained for scrolled search
search_type – Search operation type, valid choices are: ‘query_then_fetch’, ‘dfs_query_then_fetch’
size – Number of hits to return (default: 10)
sort – A comma-separated list of <field>:<direction> pairs
stats – Specific ‘tag’ of the request for logging and statistical purposes
stored_fields – A comma-separated list of stored fields to return as part of a hit
suggest_field – Specify which field to use for suggestions
suggest_mode – Specify suggest mode, default ‘missing’, valid choices are: ‘missing’, ‘popular’, ‘always’
suggest_size – How many suggestions to return in response
suggest_text – The source text for which the suggestions should be returned
terminate_after – The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
timeout – Explicit operation timeout
track_scores – Whether to calculate and return scores even if they are not used for sorting
version – Specify whether to return document version as part of a hit
- search_shards(index=None, doc_type=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 comma-separated list of index names to search; use _all or empty string to perform the operation on all indices
doc_type – A comma-separated list of document types to search; leave empty to perform the operation on all types
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
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, doc_type=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 comma-separated list of index names to search; use _all or empty string to perform the operation on all indices
doc_type – A comma-separated list of document types to search; leave empty to perform the operation on all types
body – The search definition template and its params
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
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)
routing – A comma-separated list of specific routing values
scroll – Specify how long a consistent view of the index should be maintained for scrolled search
search_type – Search operation type, valid choices are: ‘query_then_fetch’, ‘query_and_fetch’, ‘dfs_query_then_fetch’, ‘dfs_query_and_fetch’
- suggest(body, index=None, params=None)¶
The suggest feature suggests similar looking terms based on a provided text by using a suggester. http://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters.html
- Parameters
body – The request definition
index – A comma-separated list of index names to restrict the operation; 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)
preference – Specify the node or shard the operation should be performed on (default: random)
routing – Specific routing value
- termvectors(index, doc_type, 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.
doc_type – The type of the document.
id – The id of the document, when not specified a doc param should be supplied.
body – Define parameters and or supply a document to get termvectors for. See documentation.
field_statistics – Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned., default True
fields – A comma-separated list of fields to return.
offsets – Specifies if term offsets should be returned., default True
parent – Parent id of documents.
payloads – Specifies if term payloads should be returned., default True
positions – Specifies if term positions should be returned., default True
preference – Specify the node or shard the operation should be performed on (default: random).
realtime – Specifies if request is real-time as opposed to near- real-time (default: true).
routing – Specific routing value.
term_statistics – Specifies if total term frequency and document frequency should be returned., default False
version – Explicit version number for concurrency control
version_type – Specific version type, valid choices are: ‘internal’, ‘external’, ‘external_gte’, ‘force’
- update(index, doc_type, id, 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
doc_type – The type of the document
id – Document ID
body – The request definition using either script or partial doc
_source – True or false to return the _source field or not, or a list of fields to return
_source_exclude – A list of fields to exclude from the returned _source field
_source_include – A list of fields to extract and return from the _source field
fields – A comma-separated list of fields to return in the response
lang – The script language (default: groovy)
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, doc_type=None, 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 comma-separated list of index names to search; use _all or empty string to perform the operation on all indices
doc_type – A comma-separated list of document types to search; leave empty to perform the operation on all types
body – The search definition using the Query DSL
_source – True or false to return the _source field or not, or a list of fields to return
_source_exclude – A list of fields to exclude from the returned _source field
_source_include – A list of fields to extract and return from the _source field
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
analyze_wildcard – Specify whether wildcard and prefix queries should be analyzed (default: false)
analyzer – The analyzer to use for the query string
conflicts – What to do when the reindex 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
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
fielddata_fields – A comma-separated list of fields to return as the docvalue representation of a field for each 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
lowercase_expanded_terms – Specify whether query terms should be lowercased
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 set no throttle as does “unlimited” which is the only non-float this accepts., 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)
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 – Time each individual bulk request should wait for shards that are unavailable., default ‘1m’
track_scores – Whether to calculate and return scores even if they are not used for sorting
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 reindex is complete., default False
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 – The text on which the analysis should be performed
analyzer – The name of the analyzer to use
attributes – A comma-separated list of token attributes to output, this parameter works only with explain=true
char_filter – A comma-separated list of character filters to use for the analysis
explain – With true, outputs more advanced details. (default: false)
field – Use the analyzer configured for this field (instead of passing the analyzer name)
filter – A comma-separated list of filters to use for the analysis
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)
text – The text on which the analysis should be performed (when request body is not used)
tokenizer – The name of the tokenizer to use for the analysis
- 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
- 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
timeout – Explicit operation timeout
- 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
update_all_types – Whether to update the mapping for all fields with the same name across all types or not
wait_for_active_shards – Set the number of active shards to wait for before the operation returns.
- delete(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
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 indices 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)
- 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 [‘open’, ‘closed’], 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 name of the template
local – Return local information, do not retrieve the state from master node (default: false)
master_timeout – Explicit operation timeout for connection to master node
- 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
operation_threading – TODO: ?
wait_for_merge – Specify whether the request should block until the merge process is finished (default: true)
- 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
feature – A comma-separated list of features
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)
human – Whether to return version and creation date values in human- readable format., default False
ignore_unavailable – Ignore unavailable indexes (default: false)
include_defaults – Whether to return all default setting for each of the indices., default False
local – Return local information, do not retrieve the state from master node (default: false)
- get_alias(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)
- 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)
- 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)
human – Whether to return version and creation date values in human- readable format., default False
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
include_defaults – Whether to return all default setting for each of the indices., default False
local – Return local information, do not retrieve the state from master node (default: false)
- get_template(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
- 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’
human – Whether to return time and byte values in human-readable format., default False
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
- 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
timeout – Explicit timeout for the operation
- put_mapping(doc_type, body, 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
doc_type – The name of the document type
body – The mapping definition
index – A comma-separated list of index names the mapping should be added to (supports wildcards); use _all or omit to add the mapping on all indices.
allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’, valid choices are: ‘open’, ‘closed’, ‘none’, ‘all’
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
master_timeout – Specify timeout for connection to master
timeout – Explicit operation timeout
update_all_types – Whether to update the mapping for all fields with the same name across all types or not
- put_settings(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
- 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
- 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
human – Whether to return time and byte values in human-readable format., 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’
force – Force a refresh even if not required, default False
ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
operation_threading – TODO: ?
- 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.
- 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’
human – Whether to return time and byte values in human-readable format., default False
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.
- 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)
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
human – Whether to return time and byte values in human-readable format., default False
level – Return stats aggregated at cluster, index or shard level, default ‘indices’, valid choices are: ‘cluster’, ‘indices’, ‘shards’
types – A comma-separated list of document types for the indexing index metric
- update_aliases(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
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
lowercase_expanded_terms – Specify whether query terms should be lowercased
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.
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
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 priorty 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
- 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
- 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, leave empty to get information from all nodes
flat_settings – Return settings in flat format (default: false)
human – Whether to return time and byte values in human-readable 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. http://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
doc_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. http://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)
human – Whether to return time and byte values in human-readable format., default False
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. http://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
human – Whether to return time and byte values in human-readable format., default False
level – Return indices stats aggregated at node, index or shard level, default ‘node’, valid choices are: ‘node’, ‘indices’, ‘shards’
timeout – Explicit operation timeout
types – A comma-separated list of document types for the indexing index metric
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
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
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=None, 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
node_id – A comma-separated list of node IDs or names to limit the returned information; use _local to return information from the node you’re connecting to, leave empty to get information from all nodes
parent_node – Return tasks with specified parent node.
parent_task – Return tasks with specified parent task id. Set to -1 to return all.
s – Comma-separated list of column names or column aliases to sort by
v – Verbose mode. Display column headers, default False
- templates(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 SnapshotMissingException is thrown
master_timeout – Explicit operation timeout for connection to master node
- 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 SnapshotMissingException 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