Catch up to elasticsearch master

This commit is contained in:
Honza Král
2016-08-16 21:23:14 +02:00
parent c855adc6e6
commit 87bf9866a4
3 changed files with 63 additions and 27 deletions
+37 -8
View File
@@ -922,8 +922,8 @@ class Elasticsearch(object):
return self.transport.perform_request('DELETE', '/_search/scroll',
params=params, body=body)
@query_params('consistency', 'parent', 'refresh', 'routing', 'timeout',
'version', 'version_type')
@query_params('parent', 'refresh', 'routing', 'timeout', 'version',
'version_type', 'wait_for_active_shards')
def delete(self, index, doc_type, id, params=None):
"""
Delete a typed JSON document from a specific index based on its id.
@@ -932,8 +932,6 @@ class Elasticsearch(object):
:arg index: The name of the index
:arg doc_type: The type of the document
:arg id: The document ID
:arg consistency: Specific write consistency setting for the operation,
valid choices are: 'one', 'quorum', 'all'
:arg parent: ID of parent document
:arg refresh: If `true` then refresh the effected shards to make this
operation visible to search, if `wait_for` then wait for a refresh
@@ -945,6 +943,11 @@ class Elasticsearch(object):
:arg version: Explicit version number for concurrency control
:arg version_type: Specific version type, valid choices are: 'internal',
'external', 'external_gte', 'force'
:arg wait_for_active_shards: Sets the number of shard copies that must
be active before proceeding with the delete operation. Defaults to
1, meaning the primary shard only. Set to `all` for all shard
copies, otherwise set to any non-negative value less than or equal
to the total number of copies for the shard (number of replicas + 1)
"""
for param in (index, doc_type, id):
if param in SKIP_IN_PATH:
@@ -997,8 +1000,8 @@ class Elasticsearch(object):
return self.transport.perform_request('GET', _make_path(index,
doc_type, '_count'), params=params, body=body)
@query_params('consistency', 'fields', 'pipeline', 'refresh', 'routing',
'timeout')
@query_params('fields', 'pipeline', 'refresh', 'routing', 'timeout',
'wait_for_active_shards')
def bulk(self, body, index=None, doc_type=None, params=None):
"""
Perform many index/delete operations in a single API call.
@@ -1011,8 +1014,6 @@ class Elasticsearch(object):
separated by newlines
:arg index: Default index for items which don't provide one
:arg doc_type: Default document type for items which don't provide one
:arg consistency: Explicit write consistency setting for the operation,
valid choices are: 'one', 'quorum', 'all'
:arg fields: Default comma-separated list of fields to return in the
response for updates
:arg pipeline: The pipeline id to preprocess incoming documents with
@@ -1023,6 +1024,11 @@ class Elasticsearch(object):
'wait_for'
:arg routing: Specific routing value
:arg timeout: Explicit operation timeout
:arg wait_for_active_shards: Sets the number of shard copies that must
be active before proceeding with the bulk operation. Defaults to 1,
meaning the primary shard only. Set to `all` for all shard copies,
otherwise set to any non-negative value less than or equal to the
total number of copies for the shard (number of replicas + 1)
"""
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")
@@ -1426,3 +1432,26 @@ class Elasticsearch(object):
"""
return self.transport.perform_request('GET', _make_path('_render',
'template', id), params=params, body=body)
@query_params('search_type')
def msearch_template(self, body, index=None, doc_type=None, params=None):
"""
The /_search/template endpoint allows to use the mustache language to
pre render search requests, before they are executed and fill existing
templates with template parameters.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html>`_
:arg body: The request definitions (metadata-search request definition
pairs), separated by newlines
:arg index: A comma-separated list of index names to use as default
:arg doc_type: A comma-separated list of document types to use as
default
:arg search_type: Search operation type, valid choices are:
'query_then_fetch', 'query_and_fetch', 'dfs_query_then_fetch',
'dfs_query_and_fetch'
"""
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")
return self.transport.perform_request('GET', _make_path(index, doc_type,
'_msearch', 'template'), params=params, body=self._bulk_body(body))
+15 -15
View File
@@ -1,4 +1,4 @@
from .utils import NamespacedClient, query_params, _make_path
from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
class CatClient(NamespacedClient):
@query_params('h', 'help', 'local', 'master_timeout', 'v')
@@ -29,7 +29,7 @@ class CatClient(NamespacedClient):
:arg node_id: A comma-separated list of node IDs or names to limit the
returned information
:arg bytes: The unit in which to display byte values, valid choices are:
'b', 'k', 'm', 'g'
'b', 'k', 'kb', 'm', 'mb', 'g', 'gb', 't', 'tb', 'p', 'pb'
:arg h: Comma-separated list of column names to display
:arg help: Return help information, default False
:arg local: Return local information, do not retrieve the state from
@@ -156,7 +156,7 @@ class CatClient(NamespacedClient):
:arg index: A comma-separated list of index names to limit the returned
information
:arg bytes: The unit in which to display byte values, valid choices are:
'b', 'k', 'm', 'g'
'b', 'k', 'kb', 'm', 'mb', 'g', 'gb', 't', 'tb', 'p', 'pb'
:arg h: Comma-separated list of column names to display
:arg help: Return help information, default False
:arg master_timeout: Explicit operation timeout for connection to master
@@ -166,7 +166,7 @@ class CatClient(NamespacedClient):
return self.transport.perform_request('GET', _make_path('_cat',
'recovery', index), params=params)
@query_params('bytes', 'h', 'help', 'local', 'master_timeout', 'v')
@query_params('h', 'help', 'local', 'master_timeout', 'v')
def shards(self, index=None, params=None):
"""
The shards command is the detailed view of what nodes contain which shards.
@@ -174,8 +174,6 @@ class CatClient(NamespacedClient):
:arg index: A comma-separated list of index names to limit the returned
information
:arg bytes: The unit in which to display byte values, valid choices are:
'b', 'k', 'm', 'g'
:arg h: Comma-separated list of column names to display
:arg help: Return help information, default False
:arg local: Return local information, do not retrieve the state from
@@ -187,7 +185,7 @@ class CatClient(NamespacedClient):
return self.transport.perform_request('GET', _make_path('_cat',
'shards', index), params=params)
@query_params('bytes', 'h', 'help', 'v')
@query_params('h', 'help', 'v')
def segments(self, index=None, params=None):
"""
The segments command is the detailed view of Lucene segments per index.
@@ -195,8 +193,6 @@ class CatClient(NamespacedClient):
:arg index: A comma-separated list of index names to limit the returned
information
:arg bytes: The unit in which to display byte values, valid choices are:
'b', 'k', 'm', 'g'
:arg h: Comma-separated list of column names to display
:arg help: Return help information, default False
:arg v: Verbose mode. Display column headers, default False
@@ -223,13 +219,13 @@ class CatClient(NamespacedClient):
return self.transport.perform_request('GET', '/_cat/pending_tasks',
params=params)
@query_params('full_id', 'h', 'help', 'local', 'master_timeout', 'size', 'v')
def thread_pool(self, params=None):
@query_params('h', 'help', 'local', 'master_timeout', 'size',
'thread_pool_patterns', 'v')
def thread_pool(self, thread_pools=None, params=None):
"""
Get information about thread pools.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-thread-pool.html>`_
:arg full_id: Enables displaying the complete node ids, default False
:arg h: Comma-separated list of column names to display
:arg help: Return help information, default False
:arg local: Return local information, do not retrieve the state from
@@ -238,10 +234,12 @@ class CatClient(NamespacedClient):
node
:arg size: The multiplier in which to display values, valid choices are:
'', 'k', 'm', 'g', 't', 'p'
:arg thread_pool_patterns: A comma-separated list of regular-expressions
to filter the thread pools in the output
:arg v: Verbose mode. Display column headers, default False
"""
return self.transport.perform_request('GET', '/_cat/thread_pool',
params=params)
return self.transport.perform_request('GET', _make_path('_cat',
'thread_pool', thread_pools), params=params)
@query_params('bytes', 'h', 'help', 'local', 'master_timeout', 'v')
def fielddata(self, fields=None, params=None):
@@ -314,7 +312,7 @@ class CatClient(NamespacedClient):
params=params)
@query_params('h', 'help', 'ignore_unavailable', 'master_timeout', 'v')
def snapshots(self, repository=None, params=None):
def snapshots(self, repository, params=None):
"""
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-snapshots.html>`_
@@ -328,6 +326,8 @@ class CatClient(NamespacedClient):
node
:arg v: Verbose mode. Display column headers, default False
"""
if repository in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'repository'.")
return self.transport.perform_request('GET', _make_path('_cat',
'snapshots', repository), params=params)
+11 -4
View File
@@ -86,7 +86,8 @@ class IndicesClient(NamespacedClient):
return self.transport.perform_request('POST', _make_path(index,
'_flush'), params=params)
@query_params('master_timeout', 'timeout', 'update_all_types')
@query_params('master_timeout', 'timeout', 'update_all_types',
'wait_for_active_shards')
def create(self, index, body=None, params=None):
"""
Create an index in Elasticsearch.
@@ -98,6 +99,8 @@ class IndicesClient(NamespacedClient):
: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
:arg wait_for_active_shards: Set the number of active shards to wait for
before the operation returns.
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'index'.")
@@ -386,7 +389,7 @@ class IndicesClient(NamespacedClient):
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
indices that are open, closed or both., default 'all', valid
choices are: 'open', 'closed', 'none', 'all'
:arg ignore_unavailable: Whether specified concrete indices should be
ignored when unavailable (missing or closed)
@@ -839,7 +842,7 @@ class IndicesClient(NamespacedClient):
return self.transport.perform_request('POST', _make_path(index,
'_forcemerge'), params=params)
@query_params('master_timeout', 'timeout')
@query_params('master_timeout', 'timeout', 'wait_for_active_shards')
def shrink(self, index, target, body=None, params=None):
"""
The shrink index API allows you to shrink an existing index into a new
@@ -859,6 +862,8 @@ class IndicesClient(NamespacedClient):
`aliases`)
:arg master_timeout: Specify timeout for connection to master
:arg timeout: Explicit operation timeout
:arg wait_for_active_shards: Set the number of active shards to wait for
on the shrunken index before the operation returns.
"""
for param in (index, target):
if param in SKIP_IN_PATH:
@@ -866,7 +871,7 @@ class IndicesClient(NamespacedClient):
return self.transport.perform_request('PUT', _make_path(index,
'_shrink', target), params=params, body=body)
@query_params('master_timeout', 'timeout')
@query_params('master_timeout', 'timeout', 'wait_for_active_shards')
def rollover(self, alias, new_index=None, body=None, params=None):
"""
The rollover index API rolls an alias over to a new index when the
@@ -883,6 +888,8 @@ class IndicesClient(NamespacedClient):
:arg body: The conditions that needs to be met for executing rollover
:arg master_timeout: Specify timeout for connection to master
:arg timeout: Explicit operation timeout
:arg wait_for_active_shards: Set the number of active shards to wait for
on the newly created rollover index before the operation returns.
"""
if alias in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'alias'.")