Fixes for Elasticsearch 5.0

This commit is contained in:
Honza Král
2016-05-17 14:12:39 +02:00
parent b83df5e832
commit 7c305f1bc3
5 changed files with 67 additions and 57 deletions
+6 -28
View File
@@ -1048,7 +1048,7 @@ class Elasticsearch(object):
return self.transport.perform_request('GET', _make_path(index, return self.transport.perform_request('GET', _make_path(index,
doc_type, '_mtermvectors'), params=params, body=body) doc_type, '_mtermvectors'), params=params, body=body)
@query_params('op_type', 'version', 'version_type') @query_params()
def put_script(self, lang, id, body, params=None): def put_script(self, lang, id, body, params=None):
""" """
Create a script in given language with specified ID. Create a script in given language with specified ID.
@@ -1057,11 +1057,6 @@ class Elasticsearch(object):
:arg lang: Script language :arg lang: Script language
:arg id: Script ID :arg id: Script ID
:arg body: The document :arg body: The document
:arg op_type: Explicit operation type, default 'index', valid choices
are: 'index', 'create'
:arg version: Explicit version number for concurrency control
:arg version_type: Specific version type, valid choices are: 'internal',
'external', 'external_gte', 'force'
""" """
for param in (lang, id, body): for param in (lang, id, body):
if param in SKIP_IN_PATH: if param in SKIP_IN_PATH:
@@ -1069,7 +1064,7 @@ class Elasticsearch(object):
return self.transport.perform_request('PUT', _make_path('_scripts', return self.transport.perform_request('PUT', _make_path('_scripts',
lang, id), params=params, body=body) lang, id), params=params, body=body)
@query_params('version', 'version_type') @query_params()
def get_script(self, lang, id, params=None): def get_script(self, lang, id, params=None):
""" """
Retrieve a script from the API. Retrieve a script from the API.
@@ -1077,9 +1072,6 @@ class Elasticsearch(object):
:arg lang: Script language :arg lang: Script language
:arg id: Script ID :arg id: Script ID
:arg version: Explicit version number for concurrency control
:arg version_type: Specific version type, valid choices are: 'internal',
'external', 'external_gte', 'force'
""" """
for param in (lang, id): for param in (lang, id):
if param in SKIP_IN_PATH: if param in SKIP_IN_PATH:
@@ -1087,7 +1079,7 @@ class Elasticsearch(object):
return self.transport.perform_request('GET', _make_path('_scripts', return self.transport.perform_request('GET', _make_path('_scripts',
lang, id), params=params) lang, id), params=params)
@query_params('version', 'version_type') @query_params()
def delete_script(self, lang, id, params=None): def delete_script(self, lang, id, params=None):
""" """
Remove a stored script from elasticsearch. Remove a stored script from elasticsearch.
@@ -1095,9 +1087,6 @@ class Elasticsearch(object):
:arg lang: Script language :arg lang: Script language
:arg id: Script ID :arg id: Script ID
:arg version: Explicit version number for concurrency control
:arg version_type: Specific version type, valid choices are: 'internal',
'external', 'external_gte', 'force'
""" """
for param in (lang, id): for param in (lang, id):
if param in SKIP_IN_PATH: if param in SKIP_IN_PATH:
@@ -1105,7 +1094,7 @@ class Elasticsearch(object):
return self.transport.perform_request('DELETE', return self.transport.perform_request('DELETE',
_make_path('_scripts', lang, id), params=params) _make_path('_scripts', lang, id), params=params)
@query_params('op_type', 'version', 'version_type') @query_params()
def put_template(self, id, body, params=None): def put_template(self, id, body, params=None):
""" """
Create a search template. Create a search template.
@@ -1113,11 +1102,6 @@ class Elasticsearch(object):
:arg id: Template ID :arg id: Template ID
:arg body: The document :arg body: The document
:arg op_type: Explicit operation type, default 'index', valid choices
are: 'index', 'create'
:arg version: Explicit version number for concurrency control
:arg version_type: Specific version type, valid choices are: 'internal',
'external', 'external_gte', 'force'
""" """
for param in (id, body): for param in (id, body):
if param in SKIP_IN_PATH: if param in SKIP_IN_PATH:
@@ -1125,32 +1109,26 @@ class Elasticsearch(object):
return self.transport.perform_request('PUT', _make_path('_search', return self.transport.perform_request('PUT', _make_path('_search',
'template', id), params=params, body=body) 'template', id), params=params, body=body)
@query_params('version', 'version_type') @query_params()
def get_template(self, id, params=None): def get_template(self, id, params=None):
""" """
Retrieve a search template. Retrieve 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>`_
:arg id: Template ID :arg id: Template ID
:arg version: Explicit version number for concurrency control
:arg version_type: Specific version type, valid choices are: 'internal',
'external', 'external_gte', 'force'
""" """
if id in SKIP_IN_PATH: if id in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'id'.") raise ValueError("Empty value passed for a required argument 'id'.")
return self.transport.perform_request('GET', _make_path('_search', return self.transport.perform_request('GET', _make_path('_search',
'template', id), params=params) 'template', id), params=params)
@query_params('version', 'version_type') @query_params()
def delete_template(self, id, 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>`_
:arg id: Template ID :arg id: Template ID
:arg version: Explicit version number for concurrency control
:arg version_type: Specific version type, valid choices are: 'internal',
'external', 'external_gte', 'force'
""" """
if id in SKIP_IN_PATH: if id in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'id'.") raise ValueError("Empty value passed for a required argument 'id'.")
+29 -2
View File
@@ -223,7 +223,7 @@ class CatClient(NamespacedClient):
return self.transport.perform_request('GET', '/_cat/pending_tasks', return self.transport.perform_request('GET', '/_cat/pending_tasks',
params=params) params=params)
@query_params('full_id', 'h', 'help', 'local', 'master_timeout', 'v') @query_params('full_id', 'h', 'help', 'local', 'master_timeout', 'size', 'v')
def thread_pool(self, params=None): def thread_pool(self, params=None):
""" """
Get information about thread pools. Get information about thread pools.
@@ -236,6 +236,8 @@ 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 size: The multiplier in which to display values, valid choices are:
'', 'k', 'm', 'g', 't', 'p'
:arg v: Verbose mode. Display column headers, default False :arg v: Verbose mode. Display column headers, default False
""" """
return self.transport.perform_request('GET', '/_cat/thread_pool', return self.transport.perform_request('GET', '/_cat/thread_pool',
@@ -250,7 +252,7 @@ class CatClient(NamespacedClient):
:arg fields: A comma-separated list of fields to return the fielddata :arg fields: A comma-separated list of fields to return the fielddata
size size
:arg bytes: The unit in which to display byte values, valid choices are: :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 h: Comma-separated list of column names to display
:arg help: Return help information, default False :arg help: Return help information, default False
:arg local: Return local information, do not retrieve the state from :arg local: Return local information, do not retrieve the state from
@@ -328,3 +330,28 @@ class CatClient(NamespacedClient):
""" """
return self.transport.perform_request('GET', _make_path('_cat', return self.transport.perform_request('GET', _make_path('_cat',
'snapshots', repository), params=params) 'snapshots', repository), params=params)
@query_params('actions', 'detailed', 'format', 'h', 'help', 'node_id',
'parent_node', 'parent_task', 'v')
def tasks(self, params=None):
"""
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/tasks.html>`_
:arg actions: A comma-separated list of actions that should be returned.
Leave empty to return all.
:arg detailed: Return detailed task information (default: false)
:arg format: a short version of the Accept header, e.g. json, yaml
:arg h: Comma-separated list of column names to display
:arg help: Return help information, default False
:arg 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
:arg parent_node: Return tasks with specified parent node.
:arg parent_task: Return tasks with specified parent task id. Set to -1
to return all.
:arg v: Verbose mode. Display column headers, default False
"""
return self.transport.perform_request('GET', '/_cat/tasks',
params=params)
+14
View File
@@ -148,3 +148,17 @@ class ClusterClient(NamespacedClient):
return self.transport.perform_request('PUT', '/_cluster/settings', return self.transport.perform_request('PUT', '/_cluster/settings',
params=params, body=body) params=params, body=body)
@query_params('include_yes_decisions')
def allocation_explain(self, body=None, params=None):
"""
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-allocation-explain.html>`_
:arg body: The index, shard, and primary flag to explain. Empty means
'explain the first unassigned shard'
:arg include_yes_decisions: Return 'YES' decisions in explanation
(default: false)
"""
return self.transport.perform_request('GET',
'/_cluster/allocation/explain', params=params, body=body)
+7 -20
View File
@@ -1,8 +1,8 @@
from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
class IndicesClient(NamespacedClient): class IndicesClient(NamespacedClient):
@query_params('analyzer', 'attributes', 'char_filters', 'explain', 'field', @query_params('analyzer', 'attributes', 'char_filter', 'explain', 'field',
'filters', 'format', 'prefer_local', 'text', 'tokenizer') 'filter', 'format', 'prefer_local', 'text', 'tokenizer')
def analyze(self, index=None, body=None, params=None): def analyze(self, index=None, body=None, params=None):
""" """
Perform the analysis process on a text and return the tokens breakdown of the text. Perform the analysis process on a text and return the tokens breakdown of the text.
@@ -13,13 +13,13 @@ class IndicesClient(NamespacedClient):
:arg analyzer: The name of the analyzer to use :arg analyzer: The name of the analyzer to use
:arg attributes: A comma-separated list of token attributes to output, :arg attributes: A comma-separated list of token attributes to output,
this parameter works only with `explain=true` this parameter works only with `explain=true`
:arg char_filters: A comma-separated list of character filters to use :arg char_filter: A comma-separated list of character filters to use
for the analysis for the analysis
:arg explain: With `true`, outputs more advanced details. (default: :arg explain: With `true`, outputs more advanced details. (default:
false) false)
:arg field: Use the analyzer configured for this field (instead of :arg field: Use the analyzer configured for this field (instead of
passing the analyzer name) passing the analyzer name)
:arg filters: A comma-separated list of filters to use for the analysis :arg filter: A comma-separated list of filters to use for the analysis
:arg format: Format of the output, default 'detailed', valid choices :arg format: Format of the output, default 'detailed', valid choices
are: 'detailed', 'text' are: 'detailed', 'text'
:arg prefer_local: With `true`, specify that a local shard should be :arg prefer_local: With `true`, specify that a local shard should be
@@ -105,7 +105,7 @@ class IndicesClient(NamespacedClient):
params=params, body=body) params=params, body=body)
@query_params('allow_no_indices', 'expand_wildcards', 'flat_settings', @query_params('allow_no_indices', 'expand_wildcards', 'flat_settings',
'human', 'ignore_unavailable', 'local') 'human', 'ignore_unavailable', 'include_defaults', 'local')
def get(self, index, feature=None, params=None): def get(self, index, feature=None, params=None):
""" """
The get index API allows to retrieve information about one or more indexes. The get index API allows to retrieve information about one or more indexes.
@@ -122,6 +122,8 @@ class IndicesClient(NamespacedClient):
:arg human: Whether to return version and creation date values in human- :arg human: Whether to return version and creation date values in human-
readable format., default False readable format., default False
:arg ignore_unavailable: Ignore unavailable indexes (default: false) :arg ignore_unavailable: Ignore unavailable indexes (default: false)
:arg include_defaults: Whether to return all default setting for each of
the indices., default False
: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)
""" """
@@ -394,21 +396,6 @@ class IndicesClient(NamespacedClient):
return self.transport.perform_request('GET', _make_path(index, return self.transport.perform_request('GET', _make_path(index,
'_alias', name), params=params) '_alias', name), params=params)
@query_params('local', 'timeout')
def get_aliases(self, index=None, name=None, params=None):
"""
Retrieve specified aliases
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html>`_
:arg index: A comma-separated list of index names to filter aliases
:arg name: A comma-separated list of alias names to filter
:arg local: Return local information, do not retrieve the state from
master node (default: false)
:arg timeout: Explicit operation timeout
"""
return self.transport.perform_request('GET', _make_path(index,
'_aliases', name), params=params)
@query_params('master_timeout', 'timeout') @query_params('master_timeout', 'timeout')
def update_aliases(self, body, params=None): def update_aliases(self, body, params=None):
""" """
+11 -7
View File
@@ -1,23 +1,25 @@
from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
class TasksClient(NamespacedClient): class TasksClient(NamespacedClient):
@query_params('actions', 'detailed', 'node_id', 'parent_node', @query_params('actions', 'detailed', 'group_by', 'node_id', 'parent_node',
'parent_task', 'wait_for_completion') 'parent_task', 'wait_for_completion')
def list(self, task_id=None, params=None): def list(self, task_id=None, params=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/tasks-list.html>`_ `<http://www.elastic.co/guide/en/elasticsearch/reference/current/tasks-list.html>`_
:arg task_id: Return the task with specified id :arg task_id: Return the task with specified id (node_id:task_number)
:arg actions: A comma-separated list of actions that should be returned. :arg actions: A comma-separated list of actions that should be returned.
Leave empty to return all. Leave empty to return all.
:arg detailed: Return detailed task information (default: false) :arg detailed: Return detailed task information (default: false)
:arg group_by: Group tasks by nodes or parent/child relationships,
default 'nodes', valid choices are: 'nodes', 'parents'
:arg node_id: A comma-separated list of node IDs or names to limit the :arg node_id: A comma-separated list of node IDs or names to limit the
returned information; use `_local` to return information from the returned information; use `_local` to return information from the
node you're connecting to, leave empty to get information from all node you're connecting to, leave empty to get information from all
nodes nodes
:arg parent_node: Return tasks with specified parent node. :arg parent_node: Return tasks with specified parent node.
:arg parent_task: Return tasks with specified parent task id. Set to -1 :arg parent_task: Return tasks with specified parent task id
to return all. (node_id:task_number). Set to -1 to return all.
:arg wait_for_completion: Wait for the matching tasks to complete :arg wait_for_completion: Wait for the matching tasks to complete
(default: false) (default: false)
""" """
@@ -27,9 +29,11 @@ class TasksClient(NamespacedClient):
@query_params('actions', 'node_id', 'parent_node', 'parent_task') @query_params('actions', 'node_id', 'parent_node', 'parent_task')
def cancel(self, task_id=None, params=None): def cancel(self, task_id=None, params=None):
""" """
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/tasks-cancel.html>`_ `<http://www.elastic.co/guide/en/elasticsearch/reference/current/tasks-cancel.html>`_
:arg task_id: Cancel the task with specified id :arg task_id: Cancel the task with specified task id
(node_id:task_number)
:arg actions: A comma-separated list of actions that should be :arg actions: A comma-separated list of actions that should be
cancelled. Leave empty to cancel all. cancelled. Leave empty to cancel all.
:arg node_id: A comma-separated list of node IDs or names to limit the :arg node_id: A comma-separated list of node IDs or names to limit the
@@ -37,8 +41,8 @@ class TasksClient(NamespacedClient):
node you're connecting to, leave empty to get information from all node you're connecting to, leave empty to get information from all
nodes nodes
:arg parent_node: Cancel tasks with specified parent node. :arg parent_node: Cancel tasks with specified parent node.
:arg parent_task: Cancel tasks with specified parent task id. Set to -1 :arg parent_task: Cancel tasks with specified parent task id
to cancel all. (node_id:task_number). Set to -1 to cancel all.
""" """
return self.transport.perform_request('POST', _make_path('_tasks', return self.transport.perform_request('POST', _make_path('_tasks',
task_id, '_cancel'), params=params) task_id, '_cancel'), params=params)