Updated to latest 2.x compatibility

This commit is contained in:
Honza Král
2015-10-14 00:06:27 +02:00
parent 99980036e2
commit fa62ae71bf
5 changed files with 52 additions and 194 deletions
+8 -102
View File
@@ -397,8 +397,8 @@ class Elasticsearch(object):
doc_type, '_mget'), params=params, body=body) doc_type, '_mget'), params=params, body=body)
return data return data
@query_params('consistency', 'fields', 'lang', 'parent', 'refresh', @query_params('consistency', 'detect_noop', 'fields', 'lang', 'parent',
'retry_on_conflict', 'routing', 'script', 'script_id', 'refresh', 'retry_on_conflict', 'routing', 'script', 'script_id',
'scripted_upsert', 'timeout', 'timestamp', 'ttl', 'version', 'scripted_upsert', 'timeout', 'timestamp', 'ttl', 'version',
'version_type') 'version_type')
def update(self, index, doc_type, id, body=None, params=None): def update(self, index, doc_type, id, body=None, params=None):
@@ -412,6 +412,9 @@ class Elasticsearch(object):
:arg body: The request definition using either `script` or partial `doc` :arg body: The request definition using either `script` or partial `doc`
:arg consistency: Explicit write consistency setting for the operation, :arg consistency: Explicit write consistency setting for the operation,
valid choices are: 'one', 'quorum', 'all' valid choices are: 'one', 'quorum', 'all'
:arg detect_noop: Specifying as true will cause Elasticsearch to check
if there are changes and, if there arent, turn the update request
into a noop.
:arg fields: A comma-separated list of fields to return in the response :arg fields: A comma-separated list of fields to return in the response
:arg lang: The script language (default: groovy) :arg lang: The script language (default: groovy)
:arg parent: ID of the parent document. Is is only used for routing and :arg parent: ID of the parent document. Is is only used for routing and
@@ -795,42 +798,6 @@ class Elasticsearch(object):
doc_type, '_msearch'), params=params, body=self._bulk_body(body)) doc_type, '_msearch'), params=params, body=self._bulk_body(body))
return data return data
@query_params('allow_no_indices', 'analyzer', 'consistency',
'default_operator', 'df', 'expand_wildcards', 'ignore_unavailable', 'q',
'routing', 'timeout')
def delete_by_query(self, index, doc_type=None, body=None, params=None):
"""
Delete documents from one or more indices and one or more types based on a query.
`<http://www.elastic.co/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
:arg doc_type: A comma-separated list of types to restrict the operation
:arg body: A query to restrict the operation specified with the Query
DSL
: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)
:arg analyzer: The analyzer to use for the query string
:arg consistency: Specific write consistency setting for the operation
:arg default_operator: The default operator for query string query (AND
or OR), default u'OR'
:arg df: The field to use as default where no field prefix is given in
the query string
:arg expand_wildcards: Whether to expand wildcard expression to concrete
indices that are open, closed or both., default u'open'
:arg ignore_unavailable: Whether specified concrete indices should be
ignored when unavailable (missing or closed)
:arg q: Query in the Lucene query string syntax
:arg routing: Specific routing value
:arg timeout: Explicit operation timeout
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'index'.")
_, data = self.transport.perform_request('DELETE', _make_path(index, doc_type, '_query'),
params=params, body=body)
return data
@query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable',
'preference', 'routing') 'preference', 'routing')
def suggest(self, body, index=None, params=None): def suggest(self, body, index=None, params=None):
@@ -984,56 +951,6 @@ class Elasticsearch(object):
doc_type, id, '_percolate', 'count'), params=params, body=body) doc_type, id, '_percolate', 'count'), params=params, body=body)
return data return data
@query_params('boost_terms', 'include', 'max_doc_freq', 'max_query_terms',
'max_word_length', 'min_doc_freq', 'min_term_freq', 'min_word_length',
'mlt_fields', 'percent_terms_to_match', 'routing', 'search_from',
'search_indices', 'search_query_hint', 'search_scroll', 'search_size',
'search_source', 'search_type', 'search_types', 'stop_words')
def mlt(self, index, doc_type, id, body=None, params=None):
"""
Get documents that are "like" a specified document.
`<http://www.elastic.co/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)
:arg id: The document ID
:arg body: A specific search request definition
:arg boost_terms: The boost factor
:arg include: Whether to include the queried document from the response
:arg max_doc_freq: The word occurrence frequency as count: words with
higher occurrence in the corpus will be ignored
:arg max_query_terms: The maximum query terms to be included in the generated query
:arg max_word_length: The minimum length of the word: longer words will be ignored
:arg min_doc_freq: The word occurrence frequency as count: words with
lower occurrence in the corpus will be ignored
:arg min_term_freq: The term frequency as percent: terms with lower
occurence in the source document will be ignored
:arg min_word_length: The minimum length of the word: shorter words will be ignored
:arg mlt_fields: Specific fields to perform the query against
:arg percent_terms_to_match: How many terms have to match in order to
consider the document a match (default: 0.3)
:arg routing: Specific routing value
:arg search_from: The offset from which to return results
:arg search_indices: A comma-separated list of indices to perform the
query against (default: the index containing the document)
:arg search_query_hint: The search query hint
:arg search_scroll: A scroll search request definition
:arg search_size: The number of documents to return (default: 10)
:arg search_source: A specific search request definition (instead of
using the request body)
:arg search_type: Specific search type (eg. `dfs_then_fetch`, `count`, etc)
:arg search_types: A comma-separated list of types to perform the query
against (default: the same type as the document)
:arg stop_words: A list of stop words to be ignored
"""
for param in (index, doc_type, id):
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")
_, data = self.transport.perform_request('GET', _make_path(index, doc_type, id, '_mlt'),
params=params, body=body)
return data
@query_params('dfs', 'field_statistics', 'fields', 'offsets', 'parent', @query_params('dfs', 'field_statistics', 'fields', 'offsets', 'parent',
'payloads', 'positions', 'preference', 'realtime', 'routing', 'payloads', 'positions', 'preference', 'realtime', 'routing',
'term_statistics', 'version', 'version_type') 'term_statistics', 'version', 'version_type')
@@ -1083,19 +1000,6 @@ class Elasticsearch(object):
doc_type, id, '_termvectors'), params=params, body=body) doc_type, id, '_termvectors'), params=params, body=body)
return data return data
@query_params('dfs', 'field_statistics', 'fields', 'offsets', 'parent',
'payloads', 'positions', 'preference', 'realtime', 'routing',
'term_statistics', 'version', 'version_type')
def termvector(self, index, doc_type, id, body=None, params=None):
for param in (index, doc_type, id):
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")
_, data = self.transport.perform_request('GET', _make_path(index,
doc_type, id, '_termvector'), params=params, body=body)
return data
termvector.__doc__ = termvectors.__doc__
@query_params('field_statistics', 'fields', 'ids', 'offsets', 'parent', @query_params('field_statistics', 'fields', 'ids', 'offsets', 'parent',
'payloads', 'positions', 'preference', 'realtime', 'routing', 'payloads', 'positions', 'preference', 'realtime', 'routing',
'term_statistics', 'version', 'version_type') 'term_statistics', 'version', 'version_type')
@@ -1248,7 +1152,7 @@ class Elasticsearch(object):
return data return data
@query_params('version', 'version_type') @query_params('version', 'version_type')
def delete_template(self, id=None, params=None): def delete_template(self, id, params=None):
""" """
Delete a search template. Delete a search template.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html>`_ `<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html>`_
@@ -1258,6 +1162,8 @@ class Elasticsearch(object):
:arg version_type: Specific version type, valid choices are: 'internal', :arg version_type: Specific version type, valid choices are: 'internal',
'external', 'external_gte', 'force' 'external', 'external_gte', 'force'
""" """
if id in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'id'.")
_, data = self.transport.perform_request('DELETE', _make_path('_search', _, data = self.transport.perform_request('DELETE', _make_path('_search',
'template', id), params=params) 'template', id), params=params)
return data return data
+15 -15
View File
@@ -14,7 +14,7 @@ class CatClient(NamespacedClient):
master node (default: false) master node (default: false)
:arg master_timeout: Explicit operation timeout for connection to master :arg master_timeout: Explicit operation timeout for connection to master
node node
:arg v: Verbose mode. Display column headers, default True :arg v: Verbose mode. Display column headers, default False
""" """
_, data = self.transport.perform_request('GET', _make_path('_cat', _, data = self.transport.perform_request('GET', _make_path('_cat',
'aliases', name), params=params) 'aliases', name), params=params)
@@ -37,7 +37,7 @@ class CatClient(NamespacedClient):
master node (default: false) master node (default: false)
:arg master_timeout: Explicit operation timeout for connection to master :arg master_timeout: Explicit operation timeout for connection to master
node node
:arg v: Verbose mode. Display column headers, default True :arg v: Verbose mode. Display column headers, default False
""" """
_, data = self.transport.perform_request('GET', _make_path('_cat', _, data = self.transport.perform_request('GET', _make_path('_cat',
'allocation', node_id), params=params) 'allocation', node_id), params=params)
@@ -58,7 +58,7 @@ class CatClient(NamespacedClient):
master node (default: false) master node (default: false)
:arg master_timeout: Explicit operation timeout for connection to master :arg master_timeout: Explicit operation timeout for connection to master
node node
:arg v: Verbose mode. Display column headers, default True :arg v: Verbose mode. Display column headers, default False
""" """
_, data = self.transport.perform_request('GET', _make_path('_cat', _, data = self.transport.perform_request('GET', _make_path('_cat',
'count', index), params=params) 'count', index), params=params)
@@ -78,7 +78,7 @@ class CatClient(NamespacedClient):
:arg master_timeout: Explicit operation timeout for connection to master :arg master_timeout: Explicit operation timeout for connection to master
node node
:arg ts: Set to false to disable timestamping, default True :arg ts: Set to false to disable timestamping, default True
:arg v: Verbose mode. Display column headers, default True :arg v: Verbose mode. Display column headers, default False
""" """
_, data = self.transport.perform_request('GET', '/_cat/health', _, data = self.transport.perform_request('GET', '/_cat/health',
params=params) params=params)
@@ -113,7 +113,7 @@ class CatClient(NamespacedClient):
node node
:arg pri: Set to true to return stats only for primary shards, default :arg pri: Set to true to return stats only for primary shards, default
False False
:arg v: Verbose mode. Display column headers, default True :arg v: Verbose mode. Display column headers, default False
""" """
_, data = self.transport.perform_request('GET', _make_path('_cat', _, data = self.transport.perform_request('GET', _make_path('_cat',
'indices', index), params=params) 'indices', index), params=params)
@@ -131,7 +131,7 @@ class CatClient(NamespacedClient):
master node (default: false) master node (default: false)
:arg master_timeout: Explicit operation timeout for connection to master :arg master_timeout: Explicit operation timeout for connection to master
node node
:arg v: Verbose mode. Display column headers, default True :arg v: Verbose mode. Display column headers, default False
""" """
_, data = self.transport.perform_request('GET', '/_cat/master', _, data = self.transport.perform_request('GET', '/_cat/master',
params=params) params=params)
@@ -149,7 +149,7 @@ class CatClient(NamespacedClient):
master node (default: false) master node (default: false)
:arg master_timeout: Explicit operation timeout for connection to master :arg master_timeout: Explicit operation timeout for connection to master
node node
:arg v: Verbose mode. Display column headers, default True :arg v: Verbose mode. Display column headers, default False
""" """
_, data = self.transport.perform_request('GET', '/_cat/nodes', _, data = self.transport.perform_request('GET', '/_cat/nodes',
params=params) params=params)
@@ -169,7 +169,7 @@ class CatClient(NamespacedClient):
:arg help: Return help information, default False :arg help: Return help information, default False
:arg master_timeout: Explicit operation timeout for connection to master :arg master_timeout: Explicit operation timeout for connection to master
node node
:arg v: Verbose mode. Display column headers, default True :arg v: Verbose mode. Display column headers, default False
""" """
_, data = self.transport.perform_request('GET', _make_path('_cat', _, data = self.transport.perform_request('GET', _make_path('_cat',
'recovery', index), params=params) 'recovery', index), params=params)
@@ -189,7 +189,7 @@ class CatClient(NamespacedClient):
master node (default: false) master node (default: false)
:arg master_timeout: Explicit operation timeout for connection to master :arg master_timeout: Explicit operation timeout for connection to master
node node
:arg v: Verbose mode. Display column headers, default True :arg v: Verbose mode. Display column headers, default False
""" """
_, data = self.transport.perform_request('GET', _make_path('_cat', _, data = self.transport.perform_request('GET', _make_path('_cat',
'shards', index), params=params) 'shards', index), params=params)
@@ -205,7 +205,7 @@ class CatClient(NamespacedClient):
information information
:arg h: Comma-separated list of column names to display :arg h: Comma-separated list of column names to display
:arg help: Return help information, default False :arg help: Return help information, default False
:arg v: Verbose mode. Display column headers, default True :arg v: Verbose mode. Display column headers, default False
""" """
_, data = self.transport.perform_request('GET', _make_path('_cat', _, data = self.transport.perform_request('GET', _make_path('_cat',
'segments', index), params=params) 'segments', index), params=params)
@@ -225,7 +225,7 @@ class CatClient(NamespacedClient):
master node (default: false) master node (default: false)
:arg master_timeout: Explicit operation timeout for connection to master :arg master_timeout: Explicit operation timeout for connection to master
node node
:arg v: Verbose mode. Display column headers, default True :arg v: Verbose mode. Display column headers, default False
""" """
_, data = self.transport.perform_request('GET', '/_cat/pending_tasks', _, data = self.transport.perform_request('GET', '/_cat/pending_tasks',
params=params) params=params)
@@ -244,7 +244,7 @@ class CatClient(NamespacedClient):
master node (default: false) master node (default: false)
:arg master_timeout: Explicit operation timeout for connection to master :arg master_timeout: Explicit operation timeout for connection to master
node node
:arg v: Verbose mode. Display column headers, default True :arg v: Verbose mode. Display column headers, default False
""" """
_, data = self.transport.perform_request('GET', '/_cat/thread_pool', _, data = self.transport.perform_request('GET', '/_cat/thread_pool',
params=params) params=params)
@@ -266,7 +266,7 @@ class CatClient(NamespacedClient):
master node (default: false) master node (default: false)
:arg master_timeout: Explicit operation timeout for connection to master :arg master_timeout: Explicit operation timeout for connection to master
node node
:arg v: Verbose mode. Display column headers, default True :arg v: Verbose mode. Display column headers, default False
""" """
_, data = self.transport.perform_request('GET', _make_path('_cat', _, data = self.transport.perform_request('GET', _make_path('_cat',
'fielddata', fields), params=params) 'fielddata', fields), params=params)
@@ -284,7 +284,7 @@ class CatClient(NamespacedClient):
master node (default: false) master node (default: false)
:arg master_timeout: Explicit operation timeout for connection to master :arg master_timeout: Explicit operation timeout for connection to master
node node
:arg v: Verbose mode. Display column headers, default True :arg v: Verbose mode. Display column headers, default False
""" """
_, data = self.transport.perform_request('GET', '/_cat/plugins', _, data = self.transport.perform_request('GET', '/_cat/plugins',
params=params) params=params)
@@ -301,7 +301,7 @@ class CatClient(NamespacedClient):
master node (default: false) master node (default: false)
:arg master_timeout: Explicit operation timeout for connection to master :arg master_timeout: Explicit operation timeout for connection to master
node node
:arg v: Verbose mode. Display column headers, default True :arg v: Verbose mode. Display column headers, default False
""" """
_, data = self.transport.perform_request('GET', '/_cat/nodeattrs', _, data = self.transport.perform_request('GET', '/_cat/nodeattrs',
params=params) params=params)
+2 -1
View File
@@ -75,7 +75,7 @@ class ClusterClient(NamespacedClient):
'state', metric, index), params=params) 'state', metric, index), params=params)
return data return data
@query_params('flat_settings', 'human') @query_params('flat_settings', 'human', 'timeout')
def stats(self, node_id=None, params=None): def stats(self, node_id=None, params=None):
""" """
The Cluster Stats API allows to retrieve statistics from a cluster wide The Cluster Stats API allows to retrieve statistics from a cluster wide
@@ -90,6 +90,7 @@ class ClusterClient(NamespacedClient):
:arg flat_settings: Return settings in flat format (default: false) :arg flat_settings: Return settings in flat format (default: false)
:arg human: Whether to return time and byte values in human-readable :arg human: Whether to return time and byte values in human-readable
format., default False format., default False
:arg timeout: Explicit operation timeout
""" """
url = '/_cluster/stats' url = '/_cluster/stats'
if node_id: if node_id:
+21 -55
View File
@@ -86,7 +86,7 @@ class IndicesClient(NamespacedClient):
'_flush'), params=params) '_flush'), params=params)
return data return data
@query_params('master_timeout', 'timeout') @query_params('master_timeout', 'timeout', 'update_all_types')
def create(self, index, body=None, params=None): def create(self, index, body=None, params=None):
""" """
Create an index in Elasticsearch. Create an index in Elasticsearch.
@@ -96,6 +96,8 @@ class IndicesClient(NamespacedClient):
:arg body: The configuration for the index (`settings` and `mappings`) :arg body: The configuration for the index (`settings` and `mappings`)
:arg master_timeout: Specify timeout for connection to master :arg master_timeout: Specify timeout for connection to master
:arg timeout: Explicit operation timeout :arg timeout: Explicit operation timeout
:arg update_all_types: Whether to update the mapping for all fields with
the same name across all types or not
""" """
if index in SKIP_IN_PATH: if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'index'.") raise ValueError("Empty value passed for a required argument 'index'.")
@@ -258,7 +260,7 @@ class IndicesClient(NamespacedClient):
return True return True
@query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable',
'master_timeout', 'timeout') 'master_timeout', 'timeout', 'update_all_types')
def put_mapping(self, doc_type, body, index=None, params=None): def put_mapping(self, doc_type, body, index=None, params=None):
""" """
Register specific mapping definition for a specific type. Register specific mapping definition for a specific type.
@@ -279,6 +281,8 @@ class IndicesClient(NamespacedClient):
ignored when unavailable (missing or closed) ignored when unavailable (missing or closed)
:arg master_timeout: Specify timeout for connection to master :arg master_timeout: Specify timeout for connection to master
:arg timeout: Explicit operation timeout :arg timeout: Explicit operation timeout
:arg update_all_types: Whether to update the mapping for all fields with
the same name across all types or not
""" """
for param in (doc_type, body): for param in (doc_type, body):
if param in SKIP_IN_PATH: if param in SKIP_IN_PATH:
@@ -313,12 +317,12 @@ class IndicesClient(NamespacedClient):
@query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable',
'include_defaults', 'local') 'include_defaults', 'local')
def get_field_mapping(self, field, index=None, doc_type=None, params=None): def get_field_mapping(self, fields, index=None, doc_type=None, params=None):
""" """
Retrieve mapping definition of a specific field. Retrieve mapping definition of a specific field.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-field-mapping.html>`_ `<http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-field-mapping.html>`_
:arg field: A comma-separated list of fields :arg fields: A comma-separated list of fields
:arg index: A comma-separated list of index names :arg index: A comma-separated list of index names
:arg doc_type: A comma-separated list of document types :arg doc_type: A comma-separated list of document types
:arg allow_no_indices: Whether to ignore if a wildcard indices :arg allow_no_indices: Whether to ignore if a wildcard indices
@@ -334,31 +338,12 @@ class IndicesClient(NamespacedClient):
:arg local: Return local information, do not retrieve the state from :arg local: Return local information, do not retrieve the state from
master node (default: false) master node (default: false)
""" """
if field in SKIP_IN_PATH: if fields in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'field'.") raise ValueError("Empty value passed for a required argument 'fields'.")
_, data = self.transport.perform_request('GET', _make_path(index, _, data = self.transport.perform_request('GET', _make_path(index,
'_mapping', doc_type, 'field', field), params=params) '_mapping', doc_type, 'field', fields), params=params)
return data return data
@query_params('master_timeout')
def delete_mapping(self, index, doc_type, params=None):
"""
Delete a mapping (type) along with its data.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-delete-mapping.html>`_
:arg index: A comma-separated list of index names (supports wildcard);
use `_all` for all indices
:arg doc_type: A comma-separated list of document types to delete
(supports wildcards); use `_all` to delete all document types in the
specified indices.
:arg master_timeout: Specify timeout for connection to master
"""
for param in (index, doc_type):
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")
_, data = self.transport.perform_request('DELETE', _make_path(index, '_mapping', doc_type),
params=params)
return data
@query_params('master_timeout', 'timeout') @query_params('master_timeout', 'timeout')
def put_alias(self, index, name, body=None, params=None): def put_alias(self, index, name, body=None, params=None):
""" """
@@ -645,7 +630,7 @@ class IndicesClient(NamespacedClient):
ignored when unavailable (missing or closed) in the search request ignored when unavailable (missing or closed) in the search request
to warm to warm
:arg master_timeout: Specify timeout for connection to master :arg master_timeout: Specify timeout for connection to master
:arg request_cache: Specify whether the request to be wamred shoyd use :arg request_cache: Specify whether the request to be warmed should use
the request cache, defaults to index level setting the request cache, defaults to index level setting
""" """
for param in (name, body): for param in (name, body):
@@ -705,33 +690,6 @@ class IndicesClient(NamespacedClient):
'_warmer', name), params=params) '_warmer', name), params=params)
return data return data
@query_params('allow_no_indices', 'expand_wildcards', 'ignore_indices',
'ignore_unavailable', 'operation_threading', 'recovery', 'snapshot', 'human')
def status(self, index=None, params=None):
"""
Get a comprehensive status information of one or more indices.
`<http://elastic.co/guide/reference/api/admin-indices-_/>`_
:arg index: A comma-separated list of index names; use `_all` or empty
string to perform the operation on all indices
: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)
:arg expand_wildcards: Whether to expand wildcard expression to concrete indices
that are open, closed or both.
:arg ignore_indices: When performed on multiple indices, allows to
ignore `missing` ones, default u'none'
:arg ignore_unavailable: Whether specified concrete indices should be ignored
when unavailable (missing or closed)
:arg operation_threading: TODO: ?
:arg recovery: Return information about shard recovery
:arg snapshot: TODO: ?
:arg human: Whether to return time and byte values in human-readable format.
"""
_, data = self.transport.perform_request('GET', _make_path(index, '_status'),
params=params)
return data
@query_params('completion_fields', 'fielddata_fields', 'fields', 'groups', @query_params('completion_fields', 'fielddata_fields', 'fields', 'groups',
'human', 'level', 'types') 'human', 'level', 'types')
def stats(self, index=None, metric=None, params=None): def stats(self, index=None, metric=None, params=None):
@@ -962,7 +920,7 @@ class IndicesClient(NamespacedClient):
'_upgrade'), params=params) '_upgrade'), params=params)
return data return data
@query_params() @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable')
def flush_synced(self, index=None, params=None): def flush_synced(self, index=None, params=None):
""" """
Perform a normal flush, then add a generated unique marker (sync_id) to all shards. Perform a normal flush, then add a generated unique marker (sync_id) to all shards.
@@ -970,6 +928,14 @@ class IndicesClient(NamespacedClient):
:arg index: A comma-separated list of index names; use `_all` or empty :arg index: A comma-separated list of index names; use `_all` or empty
string for all indices string for all indices
: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)
:arg 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'
:arg ignore_unavailable: Whether specified concrete indices should be
ignored when unavailable (missing or closed)
""" """
_, data = self.transport.perform_request('POST', _make_path(index, _, data = self.transport.perform_request('POST', _make_path(index,
'_flush', 'synced'), params=params) '_flush', 'synced'), params=params)
+6 -21
View File
@@ -1,7 +1,7 @@
from .utils import NamespacedClient, query_params, _make_path from .utils import NamespacedClient, query_params, _make_path
class NodesClient(NamespacedClient): class NodesClient(NamespacedClient):
@query_params('flat_settings', 'human') @query_params('flat_settings', 'human', 'timeout')
def info(self, node_id=None, metric=None, params=None): def info(self, node_id=None, metric=None, params=None):
""" """
The cluster nodes info API allows to retrieve one or more (or all) of The cluster nodes info API allows to retrieve one or more (or all) of
@@ -17,31 +17,14 @@ class NodesClient(NamespacedClient):
:arg flat_settings: Return settings in flat format (default: false) :arg flat_settings: Return settings in flat format (default: false)
:arg human: Whether to return time and byte values in human-readable :arg human: Whether to return time and byte values in human-readable
format., default False format., default False
:arg timeout: Explicit operation timeout
""" """
_, data = self.transport.perform_request('GET', _make_path('_nodes', _, data = self.transport.perform_request('GET', _make_path('_nodes',
node_id, metric), params=params) node_id, metric), params=params)
return data return data
@query_params('delay', 'exit')
def shutdown(self, node_id=None, params=None):
"""
The nodes shutdown API allows to shutdown one or more (or all) nodes in
the cluster.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-shutdown.html>`_
:arg 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
:arg delay: Set the delay for the operation (default: 1s)
:arg exit: Exit the JVM as well (default: true)
"""
_, data = self.transport.perform_request('POST', _make_path('_cluster',
'nodes', node_id, '_shutdown'), params=params)
return data
@query_params('completion_fields', 'fielddata_fields', 'fields', 'groups', @query_params('completion_fields', 'fielddata_fields', 'fields', 'groups',
'human', 'level', 'types') 'human', 'level', 'timeout', 'types')
def stats(self, node_id=None, metric=None, index_metric=None, params=None): def stats(self, 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 stats API allows to retrieve one or more (or all) of
@@ -69,6 +52,7 @@ class NodesClient(NamespacedClient):
:arg level: Return indices stats aggregated at node, index or shard :arg level: Return indices stats aggregated at node, index or shard
level, default 'node', valid choices are: 'node', 'indices', level, default 'node', valid choices are: 'node', 'indices',
'shards' 'shards'
:arg timeout: Explicit operation timeout
:arg types: A comma-separated list of document types for the `indexing` :arg types: A comma-separated list of document types for the `indexing`
index metric index metric
""" """
@@ -77,7 +61,7 @@ class NodesClient(NamespacedClient):
return data return data
@query_params('doc_type', 'ignore_idle_threads', 'interval', 'snapshots', @query_params('doc_type', 'ignore_idle_threads', 'interval', 'snapshots',
'threads') 'threads', 'timeout')
def hot_threads(self, node_id=None, params=None): def hot_threads(self, node_id=None, params=None):
""" """
An API allowing to get the current hot threads on each node in the cluster. An API allowing to get the current hot threads on each node in the cluster.
@@ -96,6 +80,7 @@ class NodesClient(NamespacedClient):
:arg snapshots: Number of samples of thread stacktrace (default: 10) :arg snapshots: Number of samples of thread stacktrace (default: 10)
:arg threads: Specify the number of threads to provide information for :arg threads: Specify the number of threads to provide information for
(default: 3) (default: 3)
:arg timeout: Explicit operation timeout
""" """
# avoid python reserved words # avoid python reserved words
if params and 'type_' in params: if params and 'type_' in params: