diff --git a/elasticsearch/client/__init__.py b/elasticsearch/client/__init__.py index 9f0ee6d7..7528aeb4 100644 --- a/elasticsearch/client/__init__.py +++ b/elasticsearch/client/__init__.py @@ -397,8 +397,8 @@ class Elasticsearch(object): doc_type, '_mget'), params=params, body=body) return data - @query_params('consistency', 'fields', 'lang', 'parent', 'refresh', - 'retry_on_conflict', 'routing', 'script', 'script_id', + @query_params('consistency', 'detect_noop', 'fields', 'lang', 'parent', + 'refresh', 'retry_on_conflict', 'routing', 'script', 'script_id', 'scripted_upsert', 'timeout', 'timestamp', 'ttl', 'version', 'version_type') 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 consistency: Explicit write consistency setting for the operation, valid choices are: 'one', 'quorum', 'all' + :arg detect_noop: Specifying as true will cause Elasticsearch to check + if there are changes and, if there aren’t, turn the update request + into a noop. :arg fields: A comma-separated list of fields to return in the response :arg lang: The script language (default: groovy) :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)) 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. - ``_ - - :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', 'preference', 'routing') def suggest(self, body, index=None, params=None): @@ -984,56 +951,6 @@ class Elasticsearch(object): doc_type, id, '_percolate', 'count'), params=params, body=body) 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. - ``_ - - :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', 'payloads', 'positions', 'preference', 'realtime', 'routing', 'term_statistics', 'version', 'version_type') @@ -1083,19 +1000,6 @@ class Elasticsearch(object): doc_type, id, '_termvectors'), params=params, body=body) 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', 'payloads', 'positions', 'preference', 'realtime', 'routing', 'term_statistics', 'version', 'version_type') @@ -1248,7 +1152,7 @@ class Elasticsearch(object): return data @query_params('version', 'version_type') - def delete_template(self, id=None, params=None): + def delete_template(self, id, params=None): """ Delete a search template. ``_ @@ -1258,6 +1162,8 @@ class Elasticsearch(object): :arg version_type: Specific version type, valid choices are: 'internal', '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', 'template', id), params=params) return data diff --git a/elasticsearch/client/cat.py b/elasticsearch/client/cat.py index 1d8d7099..b2eeb1af 100644 --- a/elasticsearch/client/cat.py +++ b/elasticsearch/client/cat.py @@ -14,7 +14,7 @@ class CatClient(NamespacedClient): master node (default: false) :arg master_timeout: Explicit operation timeout for connection to master 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', 'aliases', name), params=params) @@ -37,7 +37,7 @@ class CatClient(NamespacedClient): master node (default: false) :arg master_timeout: Explicit operation timeout for connection to master 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', 'allocation', node_id), params=params) @@ -58,7 +58,7 @@ class CatClient(NamespacedClient): master node (default: false) :arg master_timeout: Explicit operation timeout for connection to master 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', 'count', index), params=params) @@ -78,7 +78,7 @@ class CatClient(NamespacedClient): :arg master_timeout: Explicit operation timeout for connection to master node :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', params=params) @@ -113,7 +113,7 @@ class CatClient(NamespacedClient): node :arg pri: Set to true to return stats only for primary shards, 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', 'indices', index), params=params) @@ -131,7 +131,7 @@ class CatClient(NamespacedClient): master node (default: false) :arg master_timeout: Explicit operation timeout for connection to master 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', params=params) @@ -149,7 +149,7 @@ class CatClient(NamespacedClient): master node (default: false) :arg master_timeout: Explicit operation timeout for connection to master 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', params=params) @@ -169,7 +169,7 @@ class CatClient(NamespacedClient): :arg help: Return help information, default False :arg master_timeout: Explicit operation timeout for connection to master 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', 'recovery', index), params=params) @@ -189,7 +189,7 @@ class CatClient(NamespacedClient): master node (default: false) :arg master_timeout: Explicit operation timeout for connection to master 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', 'shards', index), params=params) @@ -205,7 +205,7 @@ class CatClient(NamespacedClient): information :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 True + :arg v: Verbose mode. Display column headers, default False """ _, data = self.transport.perform_request('GET', _make_path('_cat', 'segments', index), params=params) @@ -225,7 +225,7 @@ class CatClient(NamespacedClient): master node (default: false) :arg master_timeout: Explicit operation timeout for connection to master 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', params=params) @@ -244,7 +244,7 @@ class CatClient(NamespacedClient): master node (default: false) :arg master_timeout: Explicit operation timeout for connection to master 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', params=params) @@ -266,7 +266,7 @@ class CatClient(NamespacedClient): master node (default: false) :arg master_timeout: Explicit operation timeout for connection to master 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', 'fielddata', fields), params=params) @@ -284,7 +284,7 @@ class CatClient(NamespacedClient): master node (default: false) :arg master_timeout: Explicit operation timeout for connection to master 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', params=params) @@ -301,7 +301,7 @@ class CatClient(NamespacedClient): master node (default: false) :arg master_timeout: Explicit operation timeout for connection to master 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', params=params) diff --git a/elasticsearch/client/cluster.py b/elasticsearch/client/cluster.py index ca0aacf4..2f9e0631 100644 --- a/elasticsearch/client/cluster.py +++ b/elasticsearch/client/cluster.py @@ -75,7 +75,7 @@ class ClusterClient(NamespacedClient): 'state', metric, index), params=params) return data - @query_params('flat_settings', 'human') + @query_params('flat_settings', 'human', 'timeout') def stats(self, node_id=None, params=None): """ 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 human: Whether to return time and byte values in human-readable format., default False + :arg timeout: Explicit operation timeout """ url = '/_cluster/stats' if node_id: diff --git a/elasticsearch/client/indices.py b/elasticsearch/client/indices.py index 7c4dc3c9..478afae9 100644 --- a/elasticsearch/client/indices.py +++ b/elasticsearch/client/indices.py @@ -86,7 +86,7 @@ class IndicesClient(NamespacedClient): '_flush'), params=params) return data - @query_params('master_timeout', 'timeout') + @query_params('master_timeout', 'timeout', 'update_all_types') def create(self, index, body=None, params=None): """ Create an index in Elasticsearch. @@ -96,6 +96,8 @@ class IndicesClient(NamespacedClient): :arg body: The configuration for the index (`settings` and `mappings`) :arg master_timeout: Specify timeout for connection to master :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: raise ValueError("Empty value passed for a required argument 'index'.") @@ -258,7 +260,7 @@ class IndicesClient(NamespacedClient): return True @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): """ Register specific mapping definition for a specific type. @@ -279,6 +281,8 @@ class IndicesClient(NamespacedClient): ignored when unavailable (missing or closed) :arg master_timeout: Specify timeout for connection to master :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): if param in SKIP_IN_PATH: @@ -313,12 +317,12 @@ class IndicesClient(NamespacedClient): @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', '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. ``_ - :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 doc_type: A comma-separated list of document types :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 master node (default: false) """ - if field in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'field'.") + if fields in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'fields'.") _, 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 - @query_params('master_timeout') - def delete_mapping(self, index, doc_type, params=None): - """ - Delete a mapping (type) along with its data. - ``_ - - :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') 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 to warm :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 """ for param in (name, body): @@ -705,33 +690,6 @@ class IndicesClient(NamespacedClient): '_warmer', name), params=params) 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. - ``_ - - :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', 'human', 'level', 'types') def stats(self, index=None, metric=None, params=None): @@ -962,7 +920,7 @@ class IndicesClient(NamespacedClient): '_upgrade'), params=params) return data - @query_params() + @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable') def flush_synced(self, index=None, params=None): """ 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 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, '_flush', 'synced'), params=params) diff --git a/elasticsearch/client/nodes.py b/elasticsearch/client/nodes.py index 13320490..b81fcf65 100644 --- a/elasticsearch/client/nodes.py +++ b/elasticsearch/client/nodes.py @@ -1,7 +1,7 @@ from .utils import NamespacedClient, query_params, _make_path class NodesClient(NamespacedClient): - @query_params('flat_settings', 'human') + @query_params('flat_settings', 'human', 'timeout') def info(self, node_id=None, metric=None, params=None): """ 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 human: Whether to return time and byte values in human-readable format., default False + :arg timeout: Explicit operation timeout """ _, data = self.transport.perform_request('GET', _make_path('_nodes', node_id, metric), params=params) 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. - ``_ - - :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', - 'human', 'level', 'types') + 'human', 'level', 'timeout', 'types') 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 @@ -69,6 +52,7 @@ class NodesClient(NamespacedClient): :arg level: Return indices stats aggregated at node, index or shard level, default 'node', valid choices are: 'node', 'indices', 'shards' + :arg timeout: Explicit operation timeout :arg types: A comma-separated list of document types for the `indexing` index metric """ @@ -77,7 +61,7 @@ class NodesClient(NamespacedClient): return data @query_params('doc_type', 'ignore_idle_threads', 'interval', 'snapshots', - 'threads') + 'threads', 'timeout') def hot_threads(self, node_id=None, params=None): """ 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 threads: Specify the number of threads to provide information for (default: 3) + :arg timeout: Explicit operation timeout """ # avoid python reserved words if params and 'type_' in params: