From ef3004277bd6f781fde9e7760ce90ee275baab58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Honza=20Kr=C3=A1l?= Date: Wed, 2 Jul 2014 16:48:25 +0200 Subject: [PATCH] Updated the API interface to latest API specs --- elasticsearch/client/__init__.py | 33 ++++++---- elasticsearch/client/cat.py | 18 +++++ elasticsearch/client/indices.py | 109 ++++++++++++++++++++----------- elasticsearch/client/snapshot.py | 14 +++- 4 files changed, 124 insertions(+), 50 deletions(-) diff --git a/elasticsearch/client/__init__.py b/elasticsearch/client/__init__.py index 07b57d1a..9c2d981a 100644 --- a/elasticsearch/client/__init__.py +++ b/elasticsearch/client/__init__.py @@ -663,28 +663,37 @@ class Elasticsearch(object): params=params, body=self._bulk_body(body)) return data - @query_params('consistency', 'allow_no_indices', 'expand_wildcards', - 'ignore_unavailable', 'replication', 'routing', 'source', 'timeout', 'q') + @query_params('allow_no_indices', 'analyzer', 'consistency', + 'default_operator', 'df', 'expand_wildcards', 'ignore_unavailable', 'q', + 'replication', 'routing', 'source', '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. ``_ - :arg index: A comma-separated list of indices to restrict the operation + :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 - :arg consistency: Specific write consistency setting for 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 'open' + 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 replication: Specific replication type (default: sync) - :arg routing: Specific routing value - :arg source: The URL-encoded query definition (instead of using the request body) :arg q: Query in the Lucene query string syntax + :arg replication: Specific replication type, default u'sync' + :arg routing: Specific routing value + :arg source: The URL-encoded query definition (instead of using the + request body) :arg timeout: Explicit operation timeout """ _, data = self.transport.perform_request('DELETE', _make_path(index, doc_type, '_query'), @@ -719,8 +728,8 @@ class Elasticsearch(object): return data @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', - 'percolate_index', 'percolate_type', 'preference', 'routing', 'version', - 'version_type') + 'percolate_format', 'percolate_index', 'percolate_type', 'preference', + 'routing', 'version', 'version_type') def percolate(self, index, doc_type, id=None, body=None, params=None): """ The percolator allows to register queries against an index, and then @@ -742,6 +751,8 @@ class Elasticsearch(object): indices that are open, closed or both., default 'open' :arg ignore_unavailable: Whether specified concrete indices should be ignored when unavailable (missing or closed) + :arg percolate_format: Return an array of matching query IDs instead of + objects :arg percolate_index: The index to percolate the document into. Defaults to index. :arg percolate_type: The type to percolate document into. Defaults to diff --git a/elasticsearch/client/cat.py b/elasticsearch/client/cat.py index a4434c14..02f43f6d 100644 --- a/elasticsearch/client/cat.py +++ b/elasticsearch/client/cat.py @@ -276,3 +276,21 @@ class CatClient(NamespacedClient): _, data = self.transport.perform_request('GET', _make_path('_cat', 'fielddata', fields), params=params) return data + + @query_params('h', 'help', 'local', 'master_timeout', 'v') + def plugins(self, params=None): + """ + ``_ + + :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 + master node (default: false) + :arg master_timeout: Explicit operation timeout for connection to master + node + :arg v: Verbose mode. Display column headers, default False + """ + _, data = self.transport.perform_request('GET', '/_cat/plugins', + params=params) + return data + diff --git a/elasticsearch/client/indices.py b/elasticsearch/client/indices.py index ba85bf5f..6b8608ca 100644 --- a/elasticsearch/client/indices.py +++ b/elasticsearch/client/indices.py @@ -2,8 +2,8 @@ from .utils import NamespacedClient, query_params, _make_path from ..exceptions import NotFoundError class IndicesClient(NamespacedClient): - @query_params('analyzer', 'field', 'filters', 'format', 'index', - 'prefer_local', 'text', 'tokenizer') + @query_params('analyzer', 'char_filters', 'field', 'filters', 'format', + 'index', 'prefer_local', 'text', 'tokenizer') def analyze(self, index=None, body=None, params=None): """ Perform the analysis process on a text and return the tokens breakdown of the text. @@ -12,6 +12,8 @@ class IndicesClient(NamespacedClient): :arg index: The name of the index to scope the operation :arg body: The text on which the analysis should be performed :arg analyzer: The name of the analyzer to use + :arg char_filters: A comma-separated list of character filters to use + for the analysis :arg field: Use the analyzer configured for this field (instead of passing the analyzer name) :arg filters: A comma-separated list of filters to use for the analysis @@ -116,15 +118,23 @@ class IndicesClient(NamespacedClient): params=params) return data - @query_params('timeout', 'master_timeout') + @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', + 'master_timeout', 'timeout') def close(self, index, params=None): """ Close an index to remove it's overhead from the cluster. Closed index is blocked for read/write operations. ``_ - :arg index: A comma-separated list of indices to delete; use `_all` or - '*' to delete all indices + :arg index: A comma-separated list of indices to close; use `_all` or + '*' to close 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 u'open' + :arg ignore_unavailable: Whether specified concrete indices should be + ignored when unavailable (missing or closed) :arg master_timeout: Specify timeout for connection to master :arg timeout: Explicit operation timeout """ @@ -147,13 +157,21 @@ class IndicesClient(NamespacedClient): params=params) return data - @query_params('local') + @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', + 'local') def exists(self, index, params=None): """ Return a boolean indicating whether given index exists. ``_ :arg index: A list of indices to check + :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 u'open' + :arg ignore_unavailable: Whether specified concrete indices should be + ignored when unavailable (missing or closed) :arg local: Return local information, do not retrieve the state from master node (default: false) """ @@ -191,29 +209,8 @@ class IndicesClient(NamespacedClient): return False return True - @query_params('allow_no_indices', 'expand_wildcards', 'ignore_indices', 'ignore_unavailable') - def snapshot_index(self, index=None, params=None): - """ - Explicitly perform a snapshot through the gateway of one or more indices (backup them). - ``_ - - :arg index: A comma-separated list of index names; use `_all` or empty - 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. - :arg ignore_indices: When performed on multiple indices, allows to - ignore `missing` ones (default: none) - :arg ignore_unavailable: Whether specified concrete indices should be ignored - when unavailable (missing or closed) - """ - _, data = self.transport.perform_request('POST', - _make_path(index, '_gateway', 'snapshot'), params=params) - return data - - @query_params('ignore_conflicts', 'timeout', 'master_timeout') + @query_params('allow_no_indices', 'expand_wildcards', 'ignore_conflicts', + 'ignore_unavailable', 'master_timeout', 'timeout') def put_mapping(self, doc_type, body, index=None, params=None): """ Register specific mapping definition for a specific type. @@ -224,8 +221,15 @@ class IndicesClient(NamespacedClient): operation on all indices. :arg doc_type: The name of the document type :arg body: The mapping definition + :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 u'open' :arg ignore_conflicts: Specify whether to ignore conflicts while updating the mapping (default: false) + :arg ignore_unavailable: Whether specified concrete indices should be + ignored when unavailable (missing or closed) :arg master_timeout: Specify timeout for connection to master :arg timeout: Explicit operation timeout """ @@ -508,35 +512,55 @@ class IndicesClient(NamespacedClient): params=params) return data - @query_params('master_timeout', 'flat_settings') + @query_params('allow_no_indices', 'expand_wildcards', 'flat_settings', + 'ignore_unavailable', 'master_timeout') def put_settings(self, body, index=None, params=None): """ Change specific index level settings in real time. ``_ + :arg body: The index settings to be updated :arg index: A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - :arg master_timeout: Specify timeout for connection to master - :arg body: The index settings to be updated + :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 u'open' :arg flat_settings: Return settings in flat format (default: false) + :arg ignore_unavailable: Whether specified concrete indices should be + ignored when unavailable (missing or closed) + :arg master_timeout: Specify timeout for connection to master """ _, data = self.transport.perform_request('PUT', _make_path(index, '_settings'), params=params, body=body) return data - @query_params('master_timeout') + @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', + 'master_timeout') def put_warmer(self, name, body, index=None, doc_type=None, params=None): """ Create an index warmer to run registered search requests to warm up the index before it is available for search. ``_ - :arg index: A comma-separated list of index names to register the warmer for; - use `_all` or empty string to perform the operation on all indices :arg name: The name of the warmer + :arg body: The search request definition for the warmer (query, filters, + facets, sorting, etc) + :arg index: A comma-separated list of index names to register the warmer + for; use `_all` or omit to perform the operation on all indices :arg doc_type: A comma-separated list of document types to register the warmer for; leave empty to perform the operation on all types - :arg body: The search request definition for the warmer (query, filters, facets, sorting, etc) + :arg 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) + :arg 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' + :arg ignore_unavailable: Whether specified concrete indices should be + ignored when unavailable (missing or closed) in the search request + to warm :arg master_timeout: Specify timeout for connection to master """ if doc_type and not index: @@ -545,7 +569,8 @@ class IndicesClient(NamespacedClient): params=params, body=body) return data - @query_params('local') + @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', + 'local') def get_warmer(self, index=None, doc_type=None, name=None, params=None): """ Retreieve an index warmer. @@ -555,7 +580,15 @@ class IndicesClient(NamespacedClient): operation; use `_all` to perform the operation on all indices :arg doc_type: A comma-separated list of document types to restrict the operation; leave empty to perform the operation on all types - :arg name: The name of the warmer (supports wildcards); leave empty to get all warmers + :arg name: The name of the warmer (supports wildcards); leave empty to + get all warmers + :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 u'open' + :arg ignore_unavailable: Whether specified concrete indices should be + ignored when unavailable (missing or closed) :arg local: Return local information, do not retrieve the state from master node (default: false) """ diff --git a/elasticsearch/client/snapshot.py b/elasticsearch/client/snapshot.py index 038f5dfe..47370ef6 100644 --- a/elasticsearch/client/snapshot.py +++ b/elasticsearch/client/snapshot.py @@ -113,5 +113,17 @@ class SnapshotClient(NamespacedClient): _, data = self.transport.perform_request('POST', _make_path('_snapshot', repository, snapshot, '_restore'), params=params, body=body) return data - + @query_params('master_timeout') + def status(self, repository=None, snapshot=None, params=None): + """ + ``_ + + :arg repository: A repository name + :arg snapshot: A comma-separated list of snapshot names + :arg master_timeout: Explicit operation timeout for connection to master + node + """ + _, data = self.transport.perform_request('GET', _make_path('_snapshot', + repository, snapshot, '_status'), params=params) + return data