elasticsearch_tornado package

Submodules

elasticsearch_tornado.cat module

class elasticsearch_tornado.cat.MeowClient(host='localhost', port=9200, prefix='', method='http', ssl=False, curl=False, verify_certs=True, ca_certs='', io_loop=None, *args, **kwargs)[source]

Bases: elasticsearch_tornado.client.BaseClient

aliases_cat(name=None, params={}, callback=None, **kwargs)[source]

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

Parameters:
  • name – A comma-separated list of alias names to return
  • h – Comma-separated list of column names to display
  • get_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
  • v – Verbose mode. Display column headers, default False
allocation_cat(node_id=None, params={}, callback=None, **kwargs)[source]

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#cat-allocation

Parameters:
  • node_id – A comma-separated list of node IDs or names to limit the returned information
  • byte_unit – The unit in which to display byte values
  • h – Comma-separated list of column names to display
  • get_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
  • v – Verbose mode. Display column headers, default False
count_cat(index=None, params={}, callback=None, **kwargs)[source]

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#cat-count

Parameters:
  • index – A comma-separated list of index names to limit the returned information
  • h – Comma-separated list of column names to display
  • get_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
  • v – Verbose mode. Display column headers, default False
fielddata_cat(fields=None, params={}, callback=None, **kwargs)[source]

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

Parameters:
  • fields – A comma-separated list of fields to return the fielddata size
  • byte_unit – The unit in which to display byte values
  • fields – A comma-separated list of fields to return the fielddata size
  • h – Comma-separated list of column names to display
  • get_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
  • v – Verbose mode. Display column headers (default: ‘false’)
health_cat(params={}, callback=None, **kwargs)[source]

health is a terse, one-line representation of the same information from health() API http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cat-health.html

Parameters:
  • h – Comma-separated list of column names to display
  • get_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
  • ts – Set to false to disable timestamping, default True
  • v – Verbose mode. Display column headers, default False
help_cat(params={}, callback=None, **kwargs)[source]

A simple help for the cat api. http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/cat.html

Parameters:get_help – Return help information, default False
indices_cat(index=None, params={}, callback=None, **kwargs)[source]

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

Parameters:
  • index – A comma-separated list of index names to limit the returned information
  • byte_unit – The unit in which to display byte values
  • h – Comma-separated list of column names to display
  • get_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
  • v – Verbose mode. Display column headers, default False
master_cat(params={}, callback=None, **kwargs)[source]

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

Parameters:
  • h – Comma-separated list of column names to display
  • get_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
  • v – Verbose mode. Display column headers, default False
nodes_cat(params={}, callback=None, **kwargs)[source]

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

Parameters:
  • h – Comma-separated list of column names to display
  • get_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
  • v – Verbose mode. Display column headers, default False
pending_tasks_cat(params={}, callback=None, **kwargs)[source]

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#cat-pending-tasks

Parameters:
  • h – Comma-separated list of column names to display
  • get_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
  • v – Verbose mode. Display column headers, default False
plugins_cat(params={}, callback=None, **kwargs)[source]

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

Parameters:
  • h – Comma-separated list of column names to display
  • get_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
  • v – Verbose mode. Display column headers, default False
recovery_cat(index=None, params={}, callback=None, **kwargs)[source]

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

Parameters:
  • index – A comma-separated list of index names to limit the returned information
  • byte_unit – The unit in which to display byte values
  • h – Comma-separated list of column names to display
  • get_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
  • v – Verbose mode. Display column headers, default False
segments_cat(index=None, params={}, callback=None, **kwargs)[source]

The segments command is the detailed view of Lucene segments per index.

Parameters:
  • index – A comma-separated list of index names to limit the returned information
  • h – Comma-separated list of column names to display
  • get_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
  • v – Verbose mode. Display column headers, default False
shards_cat(index=None, params={}, callback=None, **kwargs)[source]

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#cat-shards

Parameters:
  • index – A comma-separated list of index names to limit the returned information
  • h – Comma-separated list of column names to display
  • get_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
  • v – Verbose mode. Display column headers, default False
thread_pool_cat(params={}, callback=None, **kwargs)[source]

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

Parameters:
  • full_id – Enables displaying the complete node ids (default: ‘false’)
  • h – Comma-separated list of column names to display
  • get_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
  • v – Verbose mode. Display column headers (default: ‘false’)

elasticsearch_tornado.client module

class elasticsearch_tornado.client.BaseClient(host='localhost', port=9200, prefix='', method='http', ssl=False, curl=False, verify_certs=True, ca_certs='', io_loop=None, *args, **kwargs)[source]

Bases: object

abort_benchmark(name=None, params={}, body='', callback=None, **kwargs)[source]

Aborts a running benchmark. http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-benchmark.html :arg name: A benchmark name

benchmark(index=None, doc_type=None, body='', params={}, callback=None, **kwargs)[source]

The benchmark API provides a standard mechanism for submitting queries and measuring their performance relative to one another. http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-benchmark.html :arg index: A comma-separated list of index names; use _all or empty

string to perform the operation on all indices
Parameters:
  • doc_type – The name of the document type
  • body – The search definition using the Query DSL
  • verbose – Specify whether to return verbose statistics about each iteration (default: false)
bulk(body, index=None, doc_type=None, params={}, callback=None, **kwargs)[source]

Perform many index/delete operations in a single API call. https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html#docs-bulk

Parameters:
  • body – The operation definition and data (action-data pairs), as either a newline separated string, or a sequence of dicts to serialize (one per row).
  • index – Default index for items which don’t provide one
  • doc_type – Default document type for items which don’t provide one
  • consistency – Explicit write consistency setting for the operation
  • refresh – Refresh the index after performing the operation
  • routing – Specific routing value
  • replication – Explicitly set the replication type (default: sync)
  • timeout – Explicit operation timeout
clear_scroll(scroll_id=None, body='', params={}, callback=None, **kwargs)[source]

Clear the scroll request created by specifying the scroll parameter to search. http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-scroll.html :arg scroll_id: The scroll ID or a list of scroll IDs :arg body: A comma-separated list of scroll IDs to clear if none was

specified via the scroll_id parameter
count_percolate(index, doc_type, doc_id=None, body='', params={}, callback=None, **kwargs)[source]

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.elasticsearch.org/guide/en/elasticsearch/reference/current/search-percolate.html :arg index: The index of the document being count percolated. :arg doc_type: The type of the document being count percolated. :arg doc_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.
Parameters:
  • 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’
  • 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
create_doc(index, doc_type, body, doc_id=None, params={}, callback=None, **kwargs)[source]

Adds a typed JSON document in a specific index, making it searchable. Behind the scenes this method calls index(..., op_type=’create’) http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-index_.html :arg index: The name of the index :arg doc_type: The type of the document :arg doc_id: Document ID :arg body: The document :arg consistency: Explicit write consistency setting for the operation :arg id: Specific document ID (when the POST method is used) :arg parent: ID of the parent document :arg percolate: Percolator queries to execute while indexing the document :arg refresh: Refresh the index after performing the operation :arg replication: Specific replication type (default: sync) :arg routing: Specific routing value :arg timeout: Explicit operation timeout :arg timestamp: Explicit timestamp for the document :arg ttl: Expiration time for the document :arg version: Explicit version number for concurrency control :arg version_type: Specific version type

delete_by_query(index, doc_type=None, body='', params={}, callback=None, **kwargs)[source]

Delete documents from one or more indices and one or more types based on a query. http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-delete-by-query.html :arg index: A comma-separated list of indices to restrict the operation;

use _all to perform the operation on all indices
Parameters:
  • doc_type – A comma-separated list of types to restrict the operation
  • body – A query to restrict the operation 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)
  • analyzer – The analyzer to use for the query string
  • consistency – Specific write consistency setting for the operation
  • default_operator – The default operator for query string query (AND or OR), default u’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 u’open’
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • q – Query in the Lucene query string syntax
  • replication – Specific replication type, default u’sync’
  • routing – Specific routing value
  • source – The URL-encoded query definition (instead of using the request body)
  • timeout – Explicit operation timeout
delete_doc(index, doc_type, doc_id, params={}, callback=None, **kwargs)[source]

Delete a typed JSON document from a specific index based on its id. http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-delete.html :arg index: The name of the index :arg doc_type: The type of the document :arg doc_id: The document ID :arg consistency: Specific write consistency setting for the operation :arg parent: ID of parent document :arg refresh: Refresh the index after performing the operation :arg replication: Specific replication type (default: sync) :arg routing: Specific routing value :arg timeout: Explicit operation timeout :arg version: Explicit version number for concurrency control :arg version_type: Specific version type

delete_script(lang, script_id, params={}, callback=None, **kwargs)[source]

Remove a stored script from elasticsearch. http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-scripting.html :arg lang: Script language :arg script_id: Script ID :arg version: Explicit version number for concurrency control :arg version_type: Specific version type

delete_template(temp_id=None, params={}, callback=None, **kwargs)[source]

Delete a search template. http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-template.html :arg temp_id: Template ID

doc_count(index=None, doc_type=None, body='', params={}, callback=None, **kwargs)[source]

Execute a query and get the number of matches for that query. http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-count.html :arg index: A comma-separated list of indices to restrict the results :arg doc_type: A comma-separated list of types to restrict the results :arg body: A query to restrict the results (optional) :arg 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)
Parameters:
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both., default ‘open’
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • 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
  • source – The URL-encoded query definition (instead of using the request body)
doc_exists(index, doc_id, doc_type='_all', params={}, callback=None, **kwargs)[source]

Returns a boolean indicating whether or not given document exists in Elasticsearch. http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-get.html :arg index: The name of the index :arg doc_id: The document ID :arg doc_type: The type of the document (uses _all by default to

fetch the first document matching the ID across all types)
Parameters:
  • 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, doc_id, body='', params={}, callback=None, **kwargs)[source]

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.elasticsearch.org/guide/en/elasticsearch/reference/current/search-explain.html :arg index: The name of the index :arg doc_type: The type of the document :arg doc_id: The document ID :arg body: The query definition using the Query DSL :arg _source: True or false to return the _source field or not, or a

list of fields to return
Parameters:
  • _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)
  • df – The default field for query string query (default: _all)
  • fields – A comma-separated list of fields to return in the response
  • 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
  • source – The URL-encoded query definition (instead of using the request body)
get_doc(index, doc_id, doc_type='_all', params={}, callback=None, **kwargs)[source]

Get a typed JSON document from the index based on its id. http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-get.html :arg index: The name of the index :arg doc_id: The document ID :arg doc_type: The type of the document (uses _all by default to

fetch the first document matching the ID across all types)
Parameters:
  • _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
  • 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 – Explicit version number for concurrency control
get_script(lang, script_id, params={}, callback=None, **kwargs)[source]

Retrieve a script from the API. http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-scripting.html :arg lang: Script language :arg script_id: Script ID :arg version: Explicit version number for concurrency control :arg version_type: Specific version type

get_source(index, doc_id, doc_type='_all', params={}, callback=None, **kwargs)[source]

Get the source of a document by it’s index, type and id. http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-get.html :arg index: The name of the index :arg doc_type: The type of the document (uses _all by default to

fetch the first document matching the ID across all types)
Parameters:
  • doc_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 – Explicit version number for concurrency control
get_template(temp_id, body='', params={}, callback=None, **kwargs)[source]

Retrieve a search template. http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-template.html :arg temp_id: Template ID :arg body: The document

index_doc(index, doc_type, body, doc_id=None, params={}, callback=None, **kwargs)[source]

Adds or updates a typed JSON document in a specific index, making it searchable. http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-index_.html :arg index: The name of the index :arg doc_type: The type of the document :arg body: The document :arg doc_id: Document ID :arg consistency: Explicit write consistency setting for the operation :arg op_type: Explicit operation type (default: index) :arg parent: ID of the parent document :arg refresh: Refresh the index after performing the operation :arg replication: Specific replication type (default: sync) :arg routing: Specific routing value :arg timeout: Explicit operation timeout :arg timestamp: Explicit timestamp for the document :arg ttl: Expiration time for the document :arg version: Explicit version number for concurrency control :arg version_type: Specific version type

info(callback=None, **kwargs)[source]

Get the basic info from the current cluster.

list_benchmarks(index=None, doc_type=None, params={}, cb=None, **kwargs)[source]

View the progress of long-running benchmarks. http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-benchmark.html :arg index: A comma-separated list of index names; use _all or empty

string to perform the operation on all indices
Parameters:doc_type – The name of the document type
mget(body, index=None, doc_type=None, params={}, callback=None, **kwargs)[source]

Get multiple documents based on an index, type (optional) and ids. http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-multi-get.html :arg body: Document identifiers; can be either docs (containing full

document information) or ids (when index and type is provided in the URL.
Parameters:
  • 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
  • fields – A comma-separated list of fields to return in the response
  • 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
mk_req(url, **kwargs)[source]

Helper function to create a tornado HTTPRequest object, kwargs get passed in to create the HTTPRequest object. See: http://tornado.readthedocs.org/en/latest/httpclient.html#request-objects

mk_url(*args, **kwargs)[source]
Args get parameterized into base url:
*(foo, bar, baz) -> /foo/bar/baz
Kwargs get encoded and appended to base url:
**{‘hello’:’world’} -> /foo/bar/baz?hello=world
mlt(index, doc_type, doc_id, body='', params={}, callback=None, **kwargs)[source]

Get documents that are “like” a specified document. http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-more-like-this.html :arg index: The name of the index :arg doc_type: The type of the document (use _all to fetch the first

document matching the ID across all types)
Parameters:
  • id – The document ID
  • body – A specific search request definition
  • boost_terms – The boost factor
  • include – Whether to include the queried document from the response
  • max_doc_freq – The word occurrence frequency as count: words with higher occurrence in the corpus will be ignored
  • max_query_terms – The maximum query terms to be included in the generated query
  • max_word_length – The minimum length of the word: longer words will be ignored
  • min_doc_freq – The word occurrence frequency as count: words with lower occurrence in the corpus will be ignored
  • min_term_freq – The term frequency as percent: terms with lower occurence in the source document will be ignored
  • min_word_length – The minimum length of the word: shorter words will be ignored
  • mlt_fields – Specific fields to perform the query against
  • percent_terms_to_match – How many terms have to match in order to consider the document a match (default: 0.3)
  • routing – Specific routing value
  • search_from – The offset from which to return results
  • search_indices – A comma-separated list of indices to perform the query against (default: the index containing the document)
  • search_query_hint – The search query hint
  • search_scroll – A scroll search request definition
  • search_size – The number of documents to return (default: 10)
  • search_source – A specific search request definition (instead of using the request body)
  • search_type – Specific search type (eg. dfs_then_fetch, count, etc)
  • search_types – A comma-separated list of types to perform the query against (default: the same type as the document)
  • stop_words – A list of stop words to be ignored
mpercolate(body, index=None, doc_type=None, params={}, callback=None, **kwargs)[source]

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.elasticsearch.org/guide/en/elasticsearch/reference/current/search-percolate.html :arg index: The index of the document being count percolated to use as

default
Parameters:
  • doc_type – The type of the document being percolated to use as default.
  • body – The percolate request definitions (header & body pair), separated by newlines
  • 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’
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
msearch(body, index=None, doc_type=None, params={}, callback=None, **kwargs)[source]

Execute several search requests within the same API. http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-multi-search.html :arg body: The request definitions (metadata-search request definition

pairs), as either a newline separated string, or a sequence of dicts to serialize (one per row).
Parameters:
  • 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
mtermvectors(index=None, doc_type=None, body='', params={}, callback=None, **kwargs)[source]

Multi termvectors API allows to get multiple termvectors based on an index, type and id. http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/docs-multi-termvectors.html :arg index: The index in which the document resides. :arg doc_type: The type of the document. :arg body: Define ids, parameters or a list of parameters per document

here. You must at least provide a list of document ids. See documentation.
Parameters:
  • 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”.
  • 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
percolate(index, doc_type, doc_id=None, body='', params={}, callback=None, **kwargs)[source]

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.elasticsearch.org/guide/en/elasticsearch/reference/current/search-percolate.html :arg index: The index of the document being percolated. :arg doc_type: The type of the document being percolated. :arg doc_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.
Parameters:
  • 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’
  • 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
  • percolate_index – The index to percolate the document into. Defaults to index.
  • 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
ping(callback=None, **kwargs)[source]

Ping request to check status of elasticsearch host

put_script(lang, script_id, body, params={}, callback=None, **kwargs)[source]

Create a script in given language with specified ID. http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-scripting.html :arg lang: Script language :arg script_id: Script ID :arg body: The document :arg op_type: Explicit operation type, default u’index’ :arg version: Explicit version number for concurrency control :arg version_type: Specific version type

put_template(temp_id, body, params={}, callback=None, **kwargs)[source]

Create a search template. http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-template.html :arg temp_id: Template ID :arg body: The document

scroll(scroll_id, params={}, callback=None, **kwargs)[source]

Scroll a search request created by specifying the scroll parameter. http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-scroll.html :arg scroll_id: The scroll ID :arg scroll: Specify how long a consistent view of the index should be

maintained for scrolled search
search(index=None, doc_type=None, body='', params={}, callback=None, **kwargs)[source]

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

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
  • 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)
  • df – The field to use as default where no field prefix is given in the query string
  • explain – Specify whether to return detailed information about score computation as part of a hit
  • fields – A comma-separated list of fields to return as part of a hit
  • indices_boost – Comma-separated list of index boosts
  • lenient – Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
  • 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’
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • lowercase_expanded_terms – Specify whether query terms should be lowercased
  • from – Starting offset (default: 0)
  • preference – Specify the node or shard the operation should be performed on (default: random)
  • q – Query in the Lucene query string syntax
  • routing – A comma-separated list of specific routing values
  • scroll – Specify how long a consistent view of the index should be maintained for scrolled search
  • search_type – Search operation type
  • size – Number of hits to return (default: 10)
  • sort – A comma-separated list of <field>:<direction> pairs
  • source – The URL-encoded request definition using the Query DSL (instead of using request body)
  • stats – Specific ‘tag’ of the request for logging and statistical purposes
  • suggest_field – Specify which field to use for suggestions
  • suggest_mode – Specify suggest mode (default: missing)
  • suggest_size – How many suggestions to return in response
  • suggest_text – The source text for which the suggestions should be returned
  • timeout – Explicit operation timeout
  • version – Specify whether to return document version as part of a hit
search_shards(index=None, doc_type=None, params={}, callback=None, **kwargs)[source]

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.elasticsearch.org/guide/en/elasticsearch/reference/master/search-shards.html :arg index: The name of the index :arg doc_type: The type of the document :arg 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)
Parameters:
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both. (default: ‘“open”’)
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • local – Return local information, do not retrieve the state from master node (default: false)
  • preference – Specify the node or shard the operation should be performed on (default: random)
  • routing – Specific routing value
search_template(index=None, doc_type=None, body='', params={}, callback=None, **kwargs)[source]

A query that accepts a query template and a map of key/value pairs to fill in template parameters. http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/query-dsl-template-query.html :arg index: A comma-separated list of index names to search; use _all

or empty string to perform the operation on all indices
Parameters:
  • 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’
  • 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
suggest(body, index=None, params={}, callback=None, **kwargs)[source]

The suggest feature suggests similar looking terms based on a provided text by using a suggester. http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-search.html :arg index: A comma-separated list of index names to restrict the operation;

use _all or empty string to perform the operation on all indices
Parameters:
  • body – The request definition
  • 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’
  • 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
  • source – The URL-encoded request definition (instead of using request body)
termvector(index, doc_type, doc_id, body='', params={}, callback=None, **kwargs)[source]

Added in 1. http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-termvectors.html :arg index: The index in which the document resides. :arg doc_type: The type of the document. :arg id: The id of the document. :arg body: Define parameters. See documentation. :arg field_statistics: Specifies if document count, sum of document

frequencies and sum of total term frequencies should be returned., default True
Parameters:
  • 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
update_doc(index, doc_type, doc_id, body='', params={}, query_params={}, callback=None, **kwargs)[source]

Update a document based on a script or partial data provided. http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-update.html :arg index: The name of the index :arg doc_type: The type of the document :arg doc_id: Document ID :arg body: The request definition using either script or partial doc :arg consistency: Explicit write consistency setting for the operation :arg fields: A comma-separated list of fields to return in the response :arg lang: The script language (default: mvel) :arg parent: ID of the parent document :arg refresh: Refresh the index after performing the operation :arg replication: Specific replication type (default: sync) :arg retry_on_conflict: Specify how many times should the operation be

retried when a conflict occurs (default: 0)
Parameters:
  • routing – Specific routing value
  • script – The URL-encoded script definition (instead of using request body)
  • 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 – Explicit version number for concurrency control

elasticsearch_tornado.cluster module

class elasticsearch_tornado.cluster.ClusterClient(host='localhost', port=9200, prefix='', method='http', ssl=False, curl=False, verify_certs=True, ca_certs='', io_loop=None, *args, **kwargs)[source]

Bases: elasticsearch_tornado.client.BaseClient

cluster_get_settings(params={}, callback=None, **kwargs)[source]

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

Parameters:
  • flat_settings – Return settings in flat format (default: false)
  • master_timeout – Explicit operation timeout for connection to master node
  • timeout – Explicit operation timeout
cluster_health(index=None, params={}, callback=None, **kwargs)[source]

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

Parameters:
  • index – Limit the information returned to a specific index
  • level – Specify the level of detail for returned information, default u’cluster’
  • local – Return local information, do not retrieve the state from master node (default: false)
  • master_timeout – Explicit operation timeout for connection to master node
  • timeout – Explicit operation timeout
  • wait_for_active_shards – Wait until the specified number of shards is active
  • wait_for_nodes – Wait until the specified number of nodes is available
  • wait_for_relocating_shards – Wait until the specified number of relocating shards is finished
  • wait_for_status – Wait until cluster is in a specific state, default None
cluster_pending_tasks(params={}, callback=None, **kwargs)[source]

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.elasticsearch.org/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
cluster_put_settings(body, params={}, callback=None, **kwargs)[source]

Update cluster wide specific settings. http://www.elasticsearch.org/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)
cluster_reroute(body, params={}, callback=None, **kwargs)[source]

Explicitly execute a cluster reroute allocation command including specific commands. http://www.elasticsearch.org/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
  • filter_metadata – Don’t return cluster state metadata (default: false)
  • master_timeout – Explicit operation timeout for connection to master node
  • metric – Limit the information returned to the specified metrics. Defaults to all but metadata
  • timeout – Explicit operation timeout
cluster_state(metric=None, index=None, params={}, callback=None, **kwargs)[source]

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

Parameters:
  • metric – Limit the information returned to the specified metrics. Possible values: “_all”, “blocks”, “index_templates”, “metadata”, “nodes”, “routing_table”, “master_node”, “version”
  • index – A comma-separated list of index names; use _all or empty string to perform the operation on all indices
  • index_templates – A comma separated list to return specific index templates when returning metadata.
  • local – Return local information, do not retrieve the state from master node (default: false)
  • master_timeout – Specify timeout for connection to master
  • flat_settings – Return settings in flat format (default: false)
cluster_stats(node_id=None, params={}, callback=None, **kwargs)[source]

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. https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-stats.html#cluster-stats

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.

elasticsearch_tornado.indices module

class elasticsearch_tornado.indices.IndicesClient(host='localhost', port=9200, prefix='', method='http', ssl=False, curl=False, verify_certs=True, ca_certs='', io_loop=None, *args, **kwargs)[source]

Bases: elasticsearch_tornado.client.BaseClient

analyze_index(index=None, body=None, params={}, callback=None, **kwargs)[source]

Perform the analysis process on a text and return the tokens breakdown of the text. http://www.elasticsearch.org/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
  • char_filters – A comma-separated list of character filters to use for the analysis
  • field – Use the analyzer configured for this field (instead of passing the analyzer name)
  • filters – A comma-separated list of filters to use for the analysis
  • format – Format of the output, default u’detailed’
  • index – The name of the index to scope the operation
  • 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, body='', params={}, callback=None, **kwargs)[source]

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

Parameters:
  • index – A comma-separated list of index name to limit the operation
  • 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)
  • filter – Clear filter caches
  • filter_cache – Clear filter caches
  • filter_keys – A comma-separated list of keys to clear when using the filter_cache parameter (default: all)
  • id – Clear ID caches for parent/child
  • id_cache – Clear ID caches for parent/child
  • 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.
  • ignore_indices – When performed on multiple indices, allows to ignore missing ones (default: none)
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • index – A comma-separated list of index name to limit the operation
  • recycler – Clear the recycler cache
close_index(index, body='', params={}, callback=None, **kwargs)[source]

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

Parameters:
  • index – A comma-separated list of indices to close; use _all or ‘*’ to close 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 u’open’
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • master_timeout – Specify timeout for connection to master
  • timeout – Explicit operation timeout
create_index(index, body, params={}, callback=None, **kwargs)[source]

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

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
delete_alias(index, name, params={}, callback=None, **kwargs)[source]

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

Parameters:
  • index – A comma-separated list of index names (supports wildcards); use _all for all indices
  • name – A comma-separated list of aliases to delete (supports wildcards); use _all to delete all aliases for the specified indices.
  • master_timeout – Specify timeout for connection to master
  • timeout – Explicit timestamp for the document
delete_index(index, params={}, callback=None, **kwargs)[source]

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

Parameters:
  • index – A comma-separated list of indices to delete; use _all or ‘*’ to delete all indices
  • master_timeout – Specify timeout for connection to master
  • timeout – Explicit operation timeout
delete_mapping(index, doc_type, params={}, callback=None, **kwargs)[source]

Delete a mapping (type) along with its data. http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-delete-mapping.html

Parameters:
  • index – A comma-separated list of index names (supports wildcard); use _all for all indices
  • doc_type – A comma-separated list of document types to delete (supports wildcards); use _all to delete all document types in the specified indices.
  • master_timeout – Specify timeout for connection to master
delete_template(name, params={}, callback=None, **kwargs)[source]

Delete an index template by its name. https://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
delete_warmer(index, name, params={}, callback=None, **kwargs)[source]

Delete an index warmer. http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-warmers.html

Parameters:
  • index – A comma-separated list of index names to delete warmers from (supports wildcards); use _all to perform the operation on all indices.
  • name – A comma-separated list of warmer names to delete (supports wildcards); use _all to delete all warmers in the specified indices.
  • master_timeout – Specify timeout for connection to master
exists_alias(name, index=None, params={}, callback=None, **kwargs)[source]

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

Parameters:
  • name – A comma-separated list of alias names to return
  • index – A comma-separated list of index names to filter aliases
  • allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both.
  • ignore_indices – When performed on multiple indices, allows to ignore missing ones (default: none)
  • 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={}, callback=None, **kwargs)[source]

Return a boolean indicating whether given template exists. https://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)
flush_index(index=None, body='', params={}, callback=None, **kwargs)[source]

Explicitly flush one or more indices. http://www.elasticsearch.org/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
  • force – Whether a flush should be forced even if it is not necessarily needed ie. if no changes will be committed to the index.
  • full – If set to true a new index writer is created and settings that have been changed related to the index writer will be refreshed.
  • 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.
  • ignore_indices – When performed on multiple indices, allows to ignore missing ones (default: none)
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
get_alias(index=None, name=None, params={}, callback=None, **kwargs)[source]

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

Parameters:
  • name – A comma-separated list of alias names to return
  • index – A comma-separated list of index names to filter aliases
  • allow_no_indices – Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both.
  • ignore_indices – When performed on multiple indices, allows to ignore missing ones, default u’none’
  • 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_aliases(index=None, name=None, params={}, callback=None, **kwargs)[source]

Retrieve specified aliases https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html#indices-aliases

Parameters:
  • index – A comma-separated list of index names to filter aliases
  • name – A comma-separated list of alias names to filter
  • local – Return local information, do not retrieve the state from master node (default: false)
  • timeout – Explicit operation timeout
get_field_mapping(field, index=None, doc_type=None, params={}, callback=None, **kwargs)[source]

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

Parameters:
  • index – A comma-separated list of index names; use _all or empty string for all indices
  • doc_type – A comma-separated list of document types
  • field – A comma-separated list of fields to retrieve the mapping for
  • include_defaults – A boolean indicating whether to return default values
  • 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.
  • 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_mapping(index=None, doc_type=None, params={}, callback=None, **kwargs)[source]

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

Parameters:
  • index – A comma-separated list of index names; use _all or empty string for all indices
  • 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.
  • 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={}, callback=None, **kwargs)[source]

Retrieve settings for one or more (or all) indices. https://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
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both.
  • ignore_indices – When performed on multiple indices, allows to ignore missing ones, default u’none’
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • flat_settings – Return settings in flat format (default: false)
  • local – Return local information, do not retrieve the state from master node (default: false)
get_template(name=None, params={}, callback=None, **kwargs)[source]

Retrieve an index template by its name. https://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)
get_warmer(index=None, doc_type=None, name=None, params={}, callback=None, **kwargs)[source]

Retreieve an index warmer. http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-warmers.html

Parameters:
  • index – A comma-separated list of index names to restrict the operation; use _all 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
  • name – The name of the warmer (supports wildcards); leave empty to get all warmers
  • 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 u’open’
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • local – Return local information, do not retrieve the state from master node (default: false)
index_exists(index, params={}, callback=None, **kwargs)[source]

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

Parameters:
  • index – A 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 u’open’
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • local – Return local information, do not retrieve the state from master node (default: false)
index_exists_type(index, doc_type, params={}, callback=None, **kwargs)[source]

Check if a type/types exists in an index/indices. http://www.elasticsearch.org/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.
  • ignore_indices – When performed on multiple indices, allows to ignore missing ones (default: none)
  • 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)
indices(index, feature=None, params={}, callback=None, **kwargs)[source]

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

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)
  • ignore_unavailable – Ignore unavailable indexes (default: false)
  • local – Return local information, do not retrieve the state from master node (default: false)
open_index(index, body='', params={}, callback=None, **kwargs)[source]

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

Parameters:
  • index – The name of the index
  • master_timeout – Specify timeout for connection to master
  • timeout – Explicit operation timeout
  • 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.
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
optimize(index=None, body='', params={}, callback=None, **kwargs)[source]

Explicitly optimize one or more indices through an API. https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-optimize.html

Parameters:
  • index – A comma-separated list of index names; use _all or empty string to perform the operation on all indices
  • flush – Specify whether the index should be flushed after performing the operation (default: true)
  • 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.
  • ignore_indices – When performed on multiple indices, allows to ignore missing ones, default u’none’
  • 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)
put_alias(name, index, body, params={}, callback=None, **kwargs)[source]

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

Parameters:
  • index – A comma-separated list of index names the alias should point to (supports wildcards); use _all or omit to perform the operation on all indices.
  • name – The name of the alias to be created or updated
  • body – The settings for the alias, such as routing or filter
  • master_timeout – Specify timeout for connection to master
  • timeout – Explicit timestamp for the document
put_mapping(doc_type, body, index=None, params={}, callback=None, **kwargs)[source]

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

Parameters:
  • index – A comma-separated list of index names the alias should point to (supports wildcards); use _all or omit to perform the operation on all indices.
  • doc_type – The name of the document type
  • body – The mapping definition
  • 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 u’open’
  • ignore_conflicts – Specify whether to ignore conflicts while updating the mapping (default: false)
  • 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_settings(body, index=None, params={}, callback=None, **kwargs)[source]

Change specific index level settings in real time. https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-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 u’open’
  • flat_settings – Return settings in flat format (default: false)
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • master_timeout – Specify timeout for connection to master
put_template(name, body, params={}, callback=None, **kwargs)[source]

Create an index template that will automatically be applied to new indices created. https://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
  • order – The order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers)
  • master_timeout – Specify timeout for connection to master
  • timeout – Explicit operation timeout
  • flat_settings – Return settings in flat format (default: false)
put_warmer(name, body, index=None, doc_type=None, params={}, callback=None, **kwargs)[source]

Create an index warmer to run registered search requests to warm up the index before it is available for search. http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-warmers.html

Parameters:
  • name – The name of the warmer
  • body – The search request definition for the warmer (query, filters, facets, sorting, etc)
  • index – A comma-separated list of index names to register the warmer for; use _all or omit to perform the operation on all indices
  • doc_type – A comma-separated list of document types to register the warmer for; 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 in the search request to warm. (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, in the search request to warm., default u’open’
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed) in the search request to warm
  • master_timeout – Specify timeout for connection to master
recovery(index=None, params={}, callback=None, **kwargs)[source]

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

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(body='', index=None, params={}, callback=None, **kwargs)[source]

Explicitly refresh one or more index, making all operations performed since the last refresh available for search. http://www.elasticsearch.org/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.
  • ignore_indices – When performed on multiple indices, allows to ignore missing ones, default u’none’
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • force – Force a refresh even if not required
segments(index=None, params={}, callback=None, **kwargs)[source]

Provide low level segments information that a Lucene index (shard level) is built with. https://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.
  • ignore_indices – When performed on multiple indices, allows to ignore missing ones, default u’none’
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • human – Whether to return time and byte values in human-readable format (default: false)
snapshot_index(index=None, body='', params={}, callback=None, **kwargs)[source]

Explicitly perform a snapshot through the gateway of one or more indices (backup them). http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-gateway-snapshot.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.
  • ignore_indices – When performed on multiple indices, allows to ignore missing ones (default: none)
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
stats(index=None, metric=None, params={}, callback=None, **kwargs)[source]

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

Parameters:
  • index – A comma-separated list of index names; use _all or empty string to perform the operation on all indices
  • metric – A comma-separated list of metrics to display. Possible values: “_all”, “completion”, “docs”, “fielddata”, “filter_cache”, “flush”, “get”, “id_cache”, “indexing”, “merge”, “percolate”, “refresh”, “search”, “segments”, “store”, “warmer”
  • completion_fields – A comma-separated list of fields for completion metric (supports wildcards)
  • fielddata_fields – A comma-separated list of fields for fielddata metric (supports wildcards)
  • fields – A comma-separated list of fields for fielddata and completion metric (supports wildcards)
  • groups – A comma-separated list of search groups for search statistics
  • 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.
  • ignore_indices – When performed on multiple indices, allows to ignore missing ones (default: none)
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • human – Whether to return time and byte values in human-readable format.
  • level – Return stats aggregated at cluster, index or shard level. (“cluster”, “indices” or “shards”, default: “indices”)
  • types – A comma-separated list of document types for the indexing index metric
update_aliases(body, params={}, callback=None, **kwargs)[source]

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

Parameters:
  • body – The definition of actions to perform
  • master_timeout – Specify timeout for connection to master
  • timeout – Request timeout
validate_query(index=None, doc_type=None, body=None, params={}, callback=None, **kwargs)[source]

Validate a potentially expensive query without executing it. http://www.elasticsearch.org/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
  • explain – Return detailed information about the error
  • 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.
  • ignore_indices – When performed on multiple indices, allows to ignore missing ones (default: none)
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • operation_threading – TODO: ?
  • q – Query in the Lucene query string syntax
  • source – The URL-encoded query definition (instead of using the request body)

elasticsearch_tornado.nodes module

class elasticsearch_tornado.nodes.NodesClient(host='localhost', port=9200, prefix='', method='http', ssl=False, curl=False, verify_certs=True, ca_certs='', io_loop=None, *args, **kwargs)[source]

Bases: elasticsearch_tornado.client.BaseClient

node_hot_threads(node_id=None, params={}, callback=None, **kwargs)[source]

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

Parameters:
  • node_id – A comma-separated list of node IDs or names to limit the returned information; use _local to return information from the node you’re connecting to, leave empty to get information from all nodes
  • type – The type to sample (default: cpu)
  • 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)
node_info(node_id=None, metric=None, params={}, callback=None, **kwargs)[source]

The cluster nodes info API allows to retrieve one or more (or all) of the cluster nodes information. http://www.elasticsearch.org/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. Choices are “settings”, “os”, “process”, “jvm”, “thread_pool”, “network”, “transport”, “http”, “plugin”
  • flat_settings – Return settings in flat format (default: false)
  • human – Whether to return time and byte values in human-readable format., default False
node_shutdown(node_id=None, params={}, callback=None, **kwargs)[source]

The nodes shutdown API allows to shutdown one or more (or all) nodes in the cluster. http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/cluster-nodes-shutdown.html

Parameters:
  • node_id – A comma-separated list of node IDs or names to perform the operation on; use _local to perform the operation on the node you’re connected to, leave empty to perform the operation on all nodes
  • delay – Set the delay for the operation (default: 1s)
  • exit – Exit the JVM as well (default: true)
node_stats(node_id=None, metric=None, index_metric=None, params={}, callback=None, **kwargs)[source]

The cluster nodes stats API allows to retrieve one or more (or all) of the cluster nodes statistics. http://www.elasticsearch.org/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. Possible options are: “_all”, “breaker”, “fs”, “http”, “indices”, “jvm”, “network”, “os”, “process”, “thread_pool”, “transport”
  • 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. Possible options are: “_all”, “completion”, “docs”, “fielddata”, “filter_cache”, “flush”, “get”, “id_cache”, “indexing”, “merge”, “percolate”, “refresh”, “search”, “segments”, “store”, “warmer”
  • 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’
  • types – A comma-separated list of document types for the indexing index metric

elasticsearch_tornado.snapshot module

class elasticsearch_tornado.snapshot.SnapshotClient(host='localhost', port=9200, prefix='', method='http', ssl=False, curl=False, verify_certs=True, ca_certs='', io_loop=None, *args, **kwargs)[source]

Bases: elasticsearch_tornado.client.BaseClient

create_repository(repository, body, params={}, callback=None, **kwargs)[source]

Registers a shared file system repository. http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html

Parameters:
  • repository – A repository name
  • body – The repository definition
  • master_timeout – Explicit operation timeout for connection to master node
  • timeout – Explicit operation timeout
create_snapshot(repository, snapshot, body, params={}, callback=None, **kwargs)[source]

Create a snapshot in repository http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html

Parameters:
  • repository – A repository name
  • snapshot – A snapshot name
  • body – The snapshot definition
  • master_timeout – Explicit operation timeout for connection to master node
  • wait_for_completion – Should this request wait until the operation has completed before returning, default False
delete_repository(repository, params={}, callback=None, **kwargs)[source]

Removes a shared file system repository. http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html

Parameters:
  • repository – A comma-separated list of repository names
  • master_timeout – Explicit operation timeout for connection to master node
  • timeout – Explicit operation timeout
delete_snapshot(repository, snapshot, params={}, callback=None, **kwargs)[source]

Deletes a snapshot from a repository. http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html

Parameters:
  • repository – A repository name
  • snapshot – A snapshot name
  • master_timeout – Explicit operation timeout for connection to master node
get_repository(repository=None, params={}, callback=None, **kwargs)[source]

Return information about registered repositories. http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html

Parameters:
  • repository – A comma-separated list of repository names
  • master_timeout – Explicit operation timeout for connection to master node
  • local – Return local information, do not retrieve the state from master node (default: false)
get_snapshot(repository, snapshot, params={}, callback=None, **kwargs)[source]

Retrieve information about a snapshot. http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html

Parameters:
  • repository – A comma-separated list of repository names
  • snapshot – A comma-separated list of snapshot names
  • master_timeout – Explicit operation timeout for connection to master node
restore_snapshot(repository, snapshot, body, params={}, callback=None, **kwargs)[source]

Restore a snapshot. http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html

Parameters:
  • repository – A repository name
  • snapshot – A snapshot name
  • body – Details of what to restore
  • master_timeout – Explicit operation timeout for connection to master node
  • wait_for_completion – Should this request wait until the operation has completed before returning, default False
snapshot_status(repository=None, snapshot=None, params={}, callback=None, **kwargs)[source]

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.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-snapshots.html

Parameters:
  • repository – A repository name
  • snapshot – A comma-separated list of snapshot names
  • master_timeout – Explicit operation timeout for connection to master node
verify_repository(repository, master_timeout=10, timeout=10, body='', params={}, callback=None, **kwargs)[source]

Returns a list of nodes where repository was successfully verified or an error message if verification process failed. http://www.elasticsearch.org/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