diff --git a/elasticsearch/client/__init__.py b/elasticsearch/client/__init__.py index 1795999e..6bd8b228 100644 --- a/elasticsearch/client/__init__.py +++ b/elasticsearch/client/__init__.py @@ -184,10 +184,11 @@ class Elasticsearch(object): def ping(self, params=None): """ Returns True if the cluster is up, False otherwise. + ``_ """ try: self.transport.perform_request('HEAD', '/', params=params) - except TransportError: + except NotFoundError: return False return True @@ -195,12 +196,13 @@ class Elasticsearch(object): def info(self, params=None): """ Get the basic info from the current cluster. + ``_ """ _, data = self.transport.perform_request('GET', '/', params=params) return data - @query_params('consistency', 'parent', 'percolate', 'refresh', - 'routing', 'timeout', 'timestamp', 'ttl', 'version', 'version_type') + @query_params('consistency', 'parent', 'refresh', 'routing', + 'timeout', 'timestamp', 'ttl', 'version', 'version_type') def create(self, index, doc_type, body, id=None, params=None): """ Adds a typed JSON document in a specific index, making it searchable. @@ -210,22 +212,25 @@ class Elasticsearch(object): :arg index: The name of the index :arg doc_type: The type of the document :arg body: The document - :arg id: Specific document ID (when the POST method is used) - :arg consistency: Explicit write consistency setting for the operation + :arg id: Document ID + :arg consistency: Explicit write consistency setting for the operation, + valid choices are: 'one', 'quorum', 'all' + :arg op_type: Explicit operation type, default 'index', valid choices + are: 'index', 'create' :arg parent: ID of the parent document - :arg percolate: Percolator queries to execute while indexing the document :arg refresh: Refresh the index after performing the operation :arg routing: Specific routing value :arg timeout: Explicit operation timeout :arg timestamp: Explicit timestamp for the document :arg ttl: Expiration time for the document :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type + :arg version_type: Specific version type, valid choices are: 'internal', + 'external', 'external_gte', 'force' """ return self.index(index, doc_type, body, id=id, params=params, op_type='create') - @query_params('consistency', 'op_type', 'parent', 'refresh', - 'routing', 'timeout', 'timestamp', 'ttl', 'version', 'version_type') + @query_params('consistency', 'op_type', 'parent', 'refresh', 'routing', + 'timeout', 'timestamp', 'ttl', 'version', 'version_type') def index(self, index, doc_type, body, id=None, params=None): """ Adds or updates a typed JSON document in a specific index, making it searchable. @@ -235,8 +240,10 @@ class Elasticsearch(object): :arg doc_type: The type of the document :arg body: The document :arg id: Document ID - :arg consistency: Explicit write consistency setting for the operation - :arg op_type: Explicit operation type (default: index) + :arg consistency: Explicit write consistency setting for the operation, + valid choices are: 'one', 'quorum', 'all' + :arg op_type: Explicit operation type, default 'index', valid choices + are: 'index', 'create' :arg parent: ID of the parent document :arg refresh: Refresh the index after performing the operation :arg routing: Specific routing value @@ -244,26 +251,26 @@ class Elasticsearch(object): :arg timestamp: Explicit timestamp for the document :arg ttl: Expiration time for the document :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type + :arg version_type: Specific version type, valid choices are: 'internal', + 'external', 'external_gte', 'force' """ for param in (index, doc_type, body): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - method = 'POST' if id in SKIP_IN_PATH else 'PUT' - _, data = self.transport.perform_request(method, + _, data = self.transport.perform_request('POST' if id in SKIP_IN_PATH else 'PUT', _make_path(index, doc_type, id), params=params, body=body) return data @query_params('parent', 'preference', 'realtime', 'refresh', 'routing') - def exists(self, index, id, doc_type='_all', params=None): + def exists(self, index, doc_type, id, params=None): """ Returns a boolean indicating whether or not given document exists in Elasticsearch. ``_ :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 doc_type: The type of the document (uses `_all` by default to - fetch the first document matching the ID across all types) :arg parent: The ID of the parent document :arg preference: Specify the node or shard the operation should be performed on (default: random) @@ -277,22 +284,24 @@ class Elasticsearch(object): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") try: - self.transport.perform_request('HEAD', _make_path(index, doc_type, id), params=params) + self.transport.perform_request('HEAD', _make_path(index, doc_type, + id), params=params) except NotFoundError: return False return True @query_params('_source', '_source_exclude', '_source_include', 'fields', - 'parent', 'preference', 'realtime', 'refresh', 'routing', 'version', 'version_type') + 'parent', 'preference', 'realtime', 'refresh', 'routing', 'version', + 'version_type') def get(self, index, id, doc_type='_all', params=None): """ Get a typed JSON document from the index based on its id. ``_ :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 doc_type: The type of the document (uses `_all` by default to - fetch the first document matching the ID across all types) :arg _source: True or false to return the _source field or not, or a list of fields to return :arg _source_exclude: A list of fields to exclude from the returned @@ -309,26 +318,27 @@ class Elasticsearch(object): performing the operation :arg routing: Specific routing value :arg version: Explicit version number for concurrency control - :arg version_type: Explicit version number for concurrency control - + :arg version_type: Specific version type, valid choices are: 'internal', + 'external', 'external_gte', 'force' """ 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), - params=params) + _, data = self.transport.perform_request('GET', _make_path(index, + doc_type, id), params=params) return data - @query_params('_source', '_source_exclude', '_source_include', 'parent', 'preference', - 'realtime', 'refresh', 'routing', 'version', 'version_type') - def get_source(self, index, id, doc_type='_all', params=None): + @query_params('_source', '_source_exclude', '_source_include', 'parent', + 'preference', 'realtime', 'refresh', 'routing', 'version', + 'version_type') + def get_source(self, index, doc_type, id, params=None): """ Get the source of a document by it's index, type and id. ``_ :arg index: The name of the index - :arg doc_type: The type of the document (uses `_all` by default to - fetch the first document matching the ID across all types) + :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 _source: True or false to return the _source field or not, or a list of fields to return @@ -339,29 +349,32 @@ class Elasticsearch(object): :arg parent: The ID of the parent document :arg preference: Specify the node or shard the operation should be performed on (default: random) - :arg realtime: Specify whether to perform the operation in realtime or search mode + :arg realtime: Specify whether to perform the operation in realtime or + search mode :arg refresh: Refresh the shard containing the document before performing the operation :arg routing: Specific routing value :arg version: Explicit version number for concurrency control - :arg version_type: Explicit version number for concurrency control + :arg version_type: Specific version type, valid choices are: 'internal', + 'external', 'external_gte', 'force' """ 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, '_source'), - params=params) + _, data = self.transport.perform_request('GET', _make_path(index, + doc_type, id, '_source'), params=params) return data @query_params('_source', '_source_exclude', '_source_include', 'fields', - 'parent', 'preference', 'realtime', 'refresh', 'routing') + 'preference', 'realtime', 'refresh') def mget(self, body, index=None, doc_type=None, params=None): """ Get multiple documents based on an index, type (optional) and ids. ``_ :arg body: Document identifiers; can be either `docs` (containing full - document information) or `ids` (when index and type is provided in the URL. + document information) or `ids` (when index and type is provided in + the URL. :arg index: The name of the index :arg doc_type: The type of the document :arg _source: True or false to return the _source field or not, or a @@ -371,18 +384,17 @@ class Elasticsearch(object): :arg _source_include: A list of fields to extract and return from the _source field :arg fields: A comma-separated list of fields to return in the response - :arg parent: The ID of the parent document :arg preference: Specify the node or shard the operation should be performed on (default: random) - :arg realtime: Specify whether to perform the operation in realtime or search mode + :arg realtime: Specify whether to perform the operation in realtime or + search mode :arg refresh: Refresh the shard containing the document before performing the operation - :arg routing: Specific routing value """ if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - _, data = self.transport.perform_request('GET', _make_path(index, doc_type, '_mget'), - params=params, body=body) + _, data = self.transport.perform_request('GET', _make_path(index, + doc_type, '_mget'), params=params, body=body) return data @query_params('consistency', 'fields', 'lang', 'parent', 'refresh', @@ -398,15 +410,18 @@ class Elasticsearch(object): :arg doc_type: The type of the document :arg id: Document ID :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' :arg fields: A comma-separated list of fields to return in the response - :arg lang: The script language (default: mvel) - :arg parent: ID of the parent document + :arg lang: The script language (default: groovy) + :arg parent: ID of the parent document. Is is only used for routing and + when for the upsert request :arg refresh: Refresh the index after performing the operation :arg retry_on_conflict: Specify how many times should the operation be retried when a conflict occurs (default: 0) :arg routing: Specific routing value - :arg script: The URL-encoded script definition (instead of using request body) + :arg script: The URL-encoded script definition (instead of using request + body) :arg script_id: The id of a stored script :arg scripted_upsert: True if the script referenced in script or script_id should be called to perform inserts - defaults to false @@ -414,23 +429,24 @@ class Elasticsearch(object): :arg timestamp: Explicit timestamp for the document :arg ttl: Expiration time for the document :arg version: Explicit version number for concurrency control - :arg version_type: Explicit version number for concurrency control + :arg version_type: Specific version type, valid choices are: 'internal', + 'force' """ 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('POST', _make_path(index, doc_type, id, '_update'), - params=params, body=body) + _, data = self.transport.perform_request('POST', _make_path(index, + doc_type, id, '_update'), params=params, body=body) return data @query_params('_source', '_source_exclude', '_source_include', - 'analyze_wildcard', 'analyzer', 'default_operator', 'df', - 'explain', 'fielddata_fields', 'fields', 'indices_boost', 'lenient', - 'allow_no_indices', 'expand_wildcards', 'ignore_unavailable', - 'lowercase_expanded_terms', 'from_', 'preference', 'q', 'query_cache', - 'routing', 'scroll', 'search_type', 'size', 'sort', 'source', 'stats', - 'suggest_field', 'suggest_mode', 'suggest_size', 'suggest_text', - 'terminate_after', 'timeout', 'track_scores', 'version') + 'allow_no_indices', 'analyze_wildcard', 'analyzer', 'default_operator', + 'df', 'expand_wildcards', 'explain', 'fielddata_fields', 'fields', + 'from_', 'ignore_unavailable', 'lenient', 'lowercase_expanded_terms', + 'preference', 'q', 'request_cache', 'routing', 'scroll', 'search_type', + 'size', 'sort', 'stats', 'suggest_field', 'suggest_mode', + 'suggest_size', 'suggest_text', 'terminate_after', 'timeout', + 'track_scores', 'version') def search(self, index=None, doc_type=None, body=None, params=None): """ Execute a search query and get back search hits that match the query. @@ -438,8 +454,8 @@ class Elasticsearch(object): :arg index: A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - :arg doc_type: A comma-separated list of document types to search; - leave empty to perform the operation on all types + :arg doc_type: A comma-separated list of document types to search; leave + empty to perform the operation on all types :arg body: The search definition using the Query DSL :arg _source: True or false to return the _source field or not, or a list of fields to return @@ -447,54 +463,59 @@ class Elasticsearch(object): _source field :arg _source_include: A list of fields to extract and return from the _source field + :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 analyze_wildcard: Specify whether wildcard and prefix queries should be analyzed (default: false) :arg analyzer: The analyzer to use for the query string :arg default_operator: The default operator for query string query (AND - or OR) (default: OR) + or OR), default 'OR', valid choices are: 'AND', 'OR' :arg df: The field to use as default where no field prefix is given in the query string - :arg explain: Specify whether to return detailed information about - score computation as part of a hit + :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 explain: Specify whether to return detailed information about score + computation as part of a hit :arg fielddata_fields: A comma-separated list of fields to return as the field data representation of a field for each hit :arg fields: A comma-separated list of fields to return as part of a hit - :arg indices_boost: Comma-separated list of index boosts - :arg lenient: Specify whether format-based query failures (such as - providing text to a numeric field) should be ignored - :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' + :arg from_: Starting offset (default: 0) :arg ignore_unavailable: Whether specified concrete indices should be ignored when unavailable (missing or closed) - :arg lowercase_expanded_terms: Specify whether query terms should be lowercased - :arg from\_: Starting offset (default: 0) + :arg lenient: Specify whether format-based query failures (such as + providing text to a numeric field) should be ignored + :arg lowercase_expanded_terms: Specify whether query terms should be + lowercased :arg preference: Specify the node or shard the operation should be performed on (default: random) :arg q: Query in the Lucene query string syntax - :arg query_cache: Enable or disable caching on a per-query basis + :arg request_cache: Specify if request cache should be used for this + request or not, defaults to index level setting :arg routing: A comma-separated list of specific routing values :arg scroll: Specify how long a consistent view of the index should be maintained for scrolled search - :arg search_type: Search operation type + :arg search_type: Search operation type, valid choices are: + 'query_then_fetch', 'dfs_query_then_fetch', 'count', 'scan' :arg size: Number of hits to return (default: 10) :arg sort: A comma-separated list of : pairs - :arg source: The URL-encoded request definition using the Query DSL - (instead of using request body) - :arg stats: Specific 'tag' of the request for logging and statistical purposes + :arg stats: Specific 'tag' of the request for logging and statistical + purposes :arg suggest_field: Specify which field to use for suggestions - :arg suggest_mode: Specify suggest mode (default: missing) + :arg suggest_mode: Specify suggest mode, default 'missing', valid + choices are: 'missing', 'popular', 'always' :arg suggest_size: How many suggestions to return in response - :arg suggest_text: The source text for which the suggestions should be returned + :arg suggest_text: The source text for which the suggestions should be + returned :arg terminate_after: The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. :arg timeout: Explicit operation timeout :arg track_scores: Whether to calculate and return scores even if they are not used for sorting - :arg version: Specify whether to return document version as part of a hit + :arg version: Specify whether to return document version as part of a + hit """ # from is a reserved word so it cannot be used, use from_ instead if 'from_' in params: @@ -502,8 +523,8 @@ class Elasticsearch(object): if doc_type and not index: index = '_all' - _, data = self.transport.perform_request('GET', _make_path(index, doc_type, '_search'), - params=params, body=body) + _, data = self.transport.perform_request('GET', _make_path(index, + doc_type, '_search'), params=params, body=body) return data @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', @@ -513,7 +534,7 @@ class Elasticsearch(object): The search shards api returns the indices and shards that a search request would be executed against. This can give useful feedback for working out issues or planning optimizations with routing and shard preferences. - ``_ + ``_ :arg index: The name of the index :arg doc_type: The type of the document @@ -521,7 +542,8 @@ class Elasticsearch(object): 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"') + 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) :arg local: Return local information, do not retrieve the state from @@ -540,7 +562,7 @@ class Elasticsearch(object): """ A query that accepts a query template and a map of key/value pairs to fill in template parameters. - ``_ + ``_ :arg index: A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices @@ -551,7 +573,8 @@ class Elasticsearch(object): 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' + 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) :arg preference: Specify the node or shard the operation should be @@ -559,7 +582,9 @@ class Elasticsearch(object): :arg routing: A comma-separated list of specific routing values :arg scroll: Specify how long a consistent view of the index should be maintained for scrolled search - :arg search_type: Search operation type + :arg search_type: Search operation type, valid choices are: + 'query_then_fetch', 'query_and_fetch', 'dfs_query_then_fetch', + 'dfs_query_and_fetch', 'count', 'scan' """ _, data = self.transport.perform_request('GET', _make_path(index, doc_type, '_search', 'template'), params=params, body=body) @@ -568,7 +593,7 @@ class Elasticsearch(object): @query_params('_source', '_source_exclude', '_source_include', 'analyze_wildcard', 'analyzer', 'default_operator', 'df', 'fields', 'lenient', 'lowercase_expanded_terms', 'parent', 'preference', 'q', - 'routing', 'source') + 'routing') def explain(self, index, doc_type, id, body=None, params=None): """ The explain api computes a score explanation for a query and a specific @@ -590,25 +615,24 @@ class Elasticsearch(object): the query string query should be analyzed (default: false) :arg analyzer: The analyzer for the query string query :arg default_operator: The default operator for query string query (AND - or OR), (default: OR) + or OR), default 'OR', valid choices are: 'AND', 'OR' :arg df: The default field for query string query (default: _all) :arg fields: A comma-separated list of fields to return in the response :arg lenient: Specify whether format-based query failures (such as providing text to a numeric field) should be ignored - :arg lowercase_expanded_terms: Specify whether query terms should be lowercased + :arg lowercase_expanded_terms: Specify whether query terms should be + lowercased :arg parent: The ID of the parent document :arg preference: Specify the node or shard the operation should be performed on (default: random) :arg q: Query in the Lucene query string syntax :arg routing: Specific routing value - :arg source: The URL-encoded query definition (instead of using the - request body) """ 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, '_explain'), - params=params, body=body) + _, data = self.transport.perform_request('GET', _make_path(index, + doc_type, id, '_explain'), params=params, body=body) return data @query_params('scroll') @@ -618,7 +642,7 @@ class Elasticsearch(object): ``_ :arg scroll_id: The scroll ID - :arg body: The scroll ID if not passed by URL or query parameter + :arg body: The scroll ID if not passed by URL or query parameter. :arg scroll: Specify how long a consistent view of the index should be maintained for scrolled search """ @@ -640,12 +664,12 @@ class Elasticsearch(object): search. ``_ - :arg scroll_id: The scroll ID or a list of scroll IDs + :arg scroll_id: A comma-separated list of scroll IDs to clear :arg body: A comma-separated list of scroll IDs to clear if none was specified via the scroll_id parameter """ - _, data = self.transport.perform_request('DELETE', _make_path('_search', 'scroll', scroll_id), - body=body, params=params) + _, data = self.transport.perform_request('DELETE', _make_path('_search', + 'scroll', scroll_id), params=params, body=body) return data @query_params('consistency', 'parent', 'refresh', 'routing', 'timeout', @@ -658,24 +682,27 @@ 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 + :arg consistency: Specific write consistency setting for the operation, + valid choices are: 'one', 'quorum', 'all' :arg parent: ID of parent document :arg refresh: Refresh the index after performing the operation :arg routing: Specific routing value :arg timeout: Explicit operation timeout :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type + :arg version_type: Specific version type, valid choices are: 'internal', + 'external', 'external_gte', 'force' """ 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('DELETE', _make_path(index, doc_type, id), params=params) + _, data = self.transport.perform_request('DELETE', _make_path(index, + doc_type, id), params=params) return data @query_params('allow_no_indices', 'analyze_wildcard', 'analyzer', 'default_operator', 'df', 'expand_wildcards', 'ignore_unavailable', - 'min_score', 'lenient', 'lowercase_expanded_terms', 'min_score', - 'preference', 'q', 'routing') + 'lenient', 'lowercase_expanded_terms', 'min_score', 'preference', 'q', + 'routing') def count(self, index=None, doc_type=None, body=None, params=None): """ Execute a query and get the number of matches for that query. @@ -683,7 +710,8 @@ class Elasticsearch(object): :arg index: A comma-separated list of indices to restrict the results :arg doc_type: A comma-separated list of types to restrict the results - :arg body: A query to restrict the results (optional) + :arg body: A query to restrict the results specified with the Query DSL + (optional) :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) @@ -691,14 +719,14 @@ class Elasticsearch(object): should be analyzed (default: false) :arg analyzer: The analyzer to use for the query string :arg default_operator: The default operator for query string query (AND - or OR), default u'OR' + or OR), default 'OR', valid choices are: 'AND', '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 'open', valid + choices are: 'open', 'closed', 'none', 'all' :arg ignore_unavailable: Whether specified concrete indices should be ignored when unavailable (missing or closed) - :arg min_score: Include only documents with a specific `_score` value in the result :arg lenient: Specify whether format-based query failures (such as providing text to a numeric field) should be ignored :arg lowercase_expanded_terms: Specify whether query terms should be @@ -713,33 +741,36 @@ class Elasticsearch(object): if doc_type and not index: index = '_all' - _, data = self.transport.perform_request('POST', _make_path(index, doc_type, '_count'), - params=params, body=body) + _, data = self.transport.perform_request('POST', _make_path(index, + doc_type, '_count'), params=params, body=body) return data - @query_params('consistency', 'refresh', 'routing', 'timeout') + @query_params('consistency', 'fields', 'refresh', 'routing', 'timeout') def bulk(self, body, index=None, doc_type=None, params=None): """ Perform many index/delete operations in a single API call. - ``_ See the :func:`~elasticsearch.helpers.bulk` helper function for a more friendly API. + ``_ - :arg body: The operation definition and data (action-data pairs), as - either a newline separated string, or a sequence of dicts to - serialize (one per row). + :arg body: The operation definition and data (action-data pairs), + 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 + :arg consistency: Explicit write consistency setting for the operation, + valid choices are: 'one', 'quorum', 'all' + :arg doc_type: Default document type for items which don't provide one + :arg fields: Default comma-separated list of fields to return in the + response for updates :arg refresh: Refresh the index after performing the operation :arg routing: Specific routing value :arg timeout: Explicit operation timeout """ if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - _, data = self.transport.perform_request('POST', _make_path(index, doc_type, '_bulk'), - params=params, body=self._bulk_body(body)) + _, data = self.transport.perform_request('POST', _make_path(index, + doc_type, '_bulk'), params=params, body=self._bulk_body(body)) return data @query_params('search_type') @@ -749,16 +780,18 @@ class Elasticsearch(object): ``_ :arg body: The request definitions (metadata-search request definition - pairs), as either a newline separated string, or a sequence of - dicts to serialize (one per row). + 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 + :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', 'count', 'scan' """ if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - _, data = self.transport.perform_request('GET', _make_path(index, doc_type, '_msearch'), - params=params, body=self._bulk_body(body)) + _, data = self.transport.perform_request('GET', _make_path(index, + doc_type, '_msearch'), params=params, body=self._bulk_body(body)) return data @query_params('allow_no_indices', 'analyzer', 'consistency', @@ -803,16 +836,18 @@ class Elasticsearch(object): """ The suggest feature suggests similar looking terms based on a provided text by using a suggester. - ``_ + ``_ - :arg index: A comma-separated list of index names to restrict the operation; - use `_all` or empty string to perform the operation on all indices :arg body: The request definition + :arg index: A comma-separated list of index names to restrict the + operation; 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., default 'open' + 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) :arg preference: Specify the node or shard the operation should be @@ -821,8 +856,8 @@ class Elasticsearch(object): """ if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - _, data = self.transport.perform_request('POST', _make_path(index, '_suggest'), - params=params, body=body) + _, data = self.transport.perform_request('POST', _make_path(index, + '_suggest'), params=params, body=body) return data @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', @@ -847,11 +882,12 @@ class Elasticsearch(object): 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' + 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) :arg percolate_format: Return an array of matching query IDs instead of - objects + objects, valid choices are: 'ids' :arg percolate_index: The index to percolate the document into. Defaults to index. :arg percolate_preference: Which shard to prefer when executing the @@ -864,7 +900,8 @@ class Elasticsearch(object): performed on (default: random) :arg routing: A comma-separated list of specific routing values :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type + :arg version_type: Specific version type, valid choices are: 'internal', + 'external', 'external_gte', 'force' """ for param in (index, doc_type): if param in SKIP_IN_PATH: @@ -881,17 +918,18 @@ class Elasticsearch(object): queries that match on that doc out of the set of registered queries. ``_ + :arg body: The percolate request definitions (header & body pair), + separated by newlines :arg index: The index of the document being count percolated to use as default :arg doc_type: The type of the document being percolated to use as default. - :arg body: The percolate request definitions (header & body pair), - separated by newlines :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' + 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) """ @@ -923,7 +961,8 @@ class Elasticsearch(object): 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' + 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) :arg percolate_index: The index to count percolate the document into. @@ -934,7 +973,8 @@ class Elasticsearch(object): performed on (default: random) :arg routing: A comma-separated list of specific routing values :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type + :arg version_type: Specific version type, valid choices are: 'internal', + 'external', 'external_gte', 'force' """ for param in (index, doc_type): if param in SKIP_IN_PATH: @@ -1003,7 +1043,7 @@ class Elasticsearch(object): artificially provided by the user (Added in 1.4). Note that for documents stored in the index, this is a near realtime API as the term vectors are not available until the next refresh. - `` + ``_ :arg index: The index in which the document resides. :arg doc_type: The type of the document. @@ -1032,39 +1072,29 @@ class Elasticsearch(object): :arg term_statistics: Specifies if total term frequency and document frequency should be returned., default False :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type + :arg version_type: Specific version type, valid choices are: 'internal', + 'external', 'external_gte', 'force' """ - for param in (index, doc_type, id): + 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('GET', _make_path(index, doc_type, id, '_termvectors'), params=params, body=body) return data - @query_params('field_statistics', 'fields', 'offsets', 'parent', 'payloads', - 'positions', 'preference', 'realtime', 'routing', 'term_statistics') - 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') + 'term_statistics', 'version', 'version_type') def mtermvectors(self, index=None, doc_type=None, body=None, params=None): """ Multi termvectors API allows to get multiple termvectors based on an index, type and id. - ``_ + ``_ :arg index: The index in which the document resides. :arg doc_type: The type of the document. - :arg body: Define ids, parameters or a list of parameters per document - here. You must at least provide a list of document ids. See + :arg body: Define ids, documents, parameters or a list of parameters per + document here. You must at least provide a list of document ids. See documentation. :arg field_statistics: Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. @@ -1097,6 +1127,9 @@ class Elasticsearch(object): frequency should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs"., default False + :arg version: Explicit version number for concurrency control + :arg version_type: Specific version type, valid choices are: 'internal', + 'external', 'external_gte', 'force' """ _, data = self.transport.perform_request('GET', _make_path(index, doc_type, '_mtermvectors'), params=params, body=body) @@ -1111,9 +1144,11 @@ class Elasticsearch(object): :arg lang: Script language :arg id: Script ID :arg body: The document - :arg op_type: Explicit operation type, default u'index' + :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 + :arg version_type: Specific version type, valid choices are: 'internal', + 'external', 'external_gte', 'force' """ for param in (lang, id, body): if param in SKIP_IN_PATH: @@ -1131,7 +1166,8 @@ class Elasticsearch(object): :arg lang: Script language :arg id: Script ID :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type + :arg version_type: Specific version type, valid choices are: 'internal', + 'external', 'external_gte', 'force' """ for param in (lang, id): if param in SKIP_IN_PATH: @@ -1149,7 +1185,8 @@ class Elasticsearch(object): :arg lang: Script language :arg id: Script ID :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type + :arg version_type: Specific version type, valid choices are: 'internal', + 'external', 'external_gte', 'force' """ for param in (lang, id): if param in SKIP_IN_PATH: @@ -1166,9 +1203,11 @@ class Elasticsearch(object): :arg id: Template ID :arg body: The document - :arg op_type: Explicit operation type, default u'index' + :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 + :arg version_type: Specific version type, valid choices are: 'internal', + 'external', 'external_gte', 'force' """ for param in (id, body): if param in SKIP_IN_PATH: @@ -1185,12 +1224,13 @@ class Elasticsearch(object): :arg id: Template ID :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type + :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('GET', _make_path('_search', 'template', - id), params=params) + _, data = self.transport.perform_request('GET', _make_path('_search', + 'template', id), params=params) return data @query_params('version', 'version_type') @@ -1201,7 +1241,8 @@ class Elasticsearch(object): :arg id: Template ID :arg version: Explicit version number for concurrency control - :arg version_type: Specific version type + :arg version_type: Specific version type, valid choices are: 'internal', + 'external', 'external_gte', 'force' """ _, data = self.transport.perform_request('DELETE', _make_path('_search', 'template', id), params=params) @@ -1228,11 +1269,12 @@ class Elasticsearch(object): should be analyzed (default: false) :arg analyzer: The analyzer to use for the query string :arg default_operator: The default operator for query string query (AND - or OR), default u'OR' + or OR), default 'OR', valid choices are: 'AND', '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' + 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) :arg lenient: Specify whether format-based query failures (such as @@ -1246,37 +1288,51 @@ class Elasticsearch(object): :arg q: Query in the Lucene query string syntax :arg routing: Specific routing value """ - try: - self.transport.perform_request('POST', _make_path(index, - doc_type, '_search', 'exists'), params=params, body=body) - except NotFoundError: - return False - return True + _, data = self.transport.perform_request('POST', _make_path(index, + doc_type, '_search', 'exists'), params=params, body=body) + return data @query_params('allow_no_indices', 'expand_wildcards', 'fields', 'ignore_unavailable', 'level') - def field_stats(self, index=None, params=None): + def field_stats(self, index=None, body=None, params=None): """ The field stats api allows one to find statistical properties of a field without executing a search, but looking up measurements that are natively available in the Lucene index. - ``_ + ``_ :arg index: A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + :arg body: Field json objects containing the name and optionally a range + to filter out indices result, that have results outside the defined + bounds :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' + indices that are open, closed or both., default 'open', valid + choices are: 'open', 'closed', 'none', 'all' :arg fields: A comma-separated list of fields for to get field statistics for (min value, max value, and more) :arg ignore_unavailable: Whether specified concrete indices should be ignored when unavailable (missing or closed) :arg level: Defines if field stats should be returned on a per index - level or on a cluster wide level, default u'cluster' + level or on a cluster wide level, default 'cluster', valid choices + are: 'indices', 'cluster' """ _, data = self.transport.perform_request('GET', _make_path(index, - '_field_stats'), params=params) + '_field_stats'), params=params, body=body) + return data + + @query_params() + def render_search_template(self, id=None, body=None, params=None): + """ + ``_ + + :arg id: The id of the stored search template + :arg body: The search definition template and its params + """ + _, data = self.transport.perform_request('GET', _make_path('_render', + 'template', id), params=params, body=body) return data diff --git a/elasticsearch/client/cat.py b/elasticsearch/client/cat.py index f79ba54f..f1781c8e 100644 --- a/elasticsearch/client/cat.py +++ b/elasticsearch/client/cat.py @@ -4,7 +4,8 @@ class CatClient(NamespacedClient): @query_params('h', 'help', 'local', 'master_timeout', 'v') def aliases(self, name=None, params=None): """ - ``_ + + ``_ :arg name: A comma-separated list of alias names to return :arg h: Comma-separated list of column names to display @@ -13,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 False + :arg v: Verbose mode. Display column headers, default True """ _, data = self.transport.perform_request('GET', _make_path('_cat', 'aliases', name), params=params) @@ -24,18 +25,19 @@ class CatClient(NamespacedClient): """ Allocation provides a snapshot of how shards have located around the cluster and the state of disk usage. - ``_ + ``_ :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 + :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 master node (default: false) :arg master_timeout: Explicit operation timeout for connection to master node - :arg v: Verbose mode. Display column headers, default False + :arg v: Verbose mode. Display column headers, default True """ _, data = self.transport.perform_request('GET', _make_path('_cat', 'allocation', node_id), params=params) @@ -46,7 +48,7 @@ class CatClient(NamespacedClient): """ Count provides quick access to the document count of the entire cluster, or individual indices. - ``_ + ``_ :arg index: A comma-separated list of index names to limit the returned information @@ -56,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 False + :arg v: Verbose mode. Display column headers, default True """ _, data = self.transport.perform_request('GET', _make_path('_cat', 'count', index), params=params) @@ -67,7 +69,7 @@ class CatClient(NamespacedClient): """ health is a terse, one-line representation of the same information from :meth:`~elasticsearch.client.cluster.ClusterClient.health` API - ``_ + ``_ :arg h: Comma-separated list of column names to display :arg help: Return help information, default False @@ -76,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 False + :arg v: Verbose mode. Display column headers, default True """ _, data = self.transport.perform_request('GET', '/_cat/health', params=params) @@ -86,7 +88,7 @@ class CatClient(NamespacedClient): def help(self, params=None): """ A simple help for the cat api. - ``_ + ``_ :arg help: Return help information, default False """ @@ -97,11 +99,12 @@ class CatClient(NamespacedClient): def indices(self, index=None, params=None): """ The indices command provides a cross-section of each index. - ``_ + ``_ :arg index: A comma-separated list of index names to limit the returned information - :arg bytes: The unit in which to display byte values + :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 @@ -110,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 False + :arg v: Verbose mode. Display column headers, default True """ _, data = self.transport.perform_request('GET', _make_path('_cat', 'indices', index), params=params) @@ -120,7 +123,7 @@ class CatClient(NamespacedClient): def master(self, params=None): """ Displays the master's node ID, bound IP address, and node name. - ``_ + ``_ :arg h: Comma-separated list of column names to display :arg help: Return help information, default False @@ -128,90 +131,81 @@ 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 False + :arg v: Verbose mode. Display column headers, default True """ _, data = self.transport.perform_request('GET', '/_cat/master', params=params) return data - @query_params('bytes', 'h', 'help', 'local', 'master_timeout', 'time', 'v') + @query_params('h', 'help', 'local', 'master_timeout', 'v') def nodes(self, params=None): """ The nodes command shows the cluster topology. - ``_ + ``_ - :arg bytes: The unit in which to display byte values :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 time: The unit in which to display time values - :arg v: Verbose mode. Display column headers, default False + :arg v: Verbose mode. Display column headers, default True """ _, data = self.transport.perform_request('GET', '/_cat/nodes', params=params) return data - @query_params('bytes', 'h', 'help', 'local', 'master_timeout', 'v') + @query_params('bytes', 'h', 'help', 'master_timeout', 'v') def recovery(self, index=None, params=None): """ recovery is a view of shard replication. - ``_ + ``_ :arg index: A comma-separated list of index names to limit the returned information - :arg bytes: The unit in which to display byte values + :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 - master node (default: false) :arg master_timeout: Explicit operation timeout for connection to master node - :arg v: Verbose mode. Display column headers, default False + :arg v: Verbose mode. Display column headers, default True """ _, data = self.transport.perform_request('GET', _make_path('_cat', 'recovery', index), params=params) return data - @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. - ``_ + ``_ :arg index: A comma-separated list of index names to limit the returned information - :arg bytes: The unit in which to display byte values :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 + :arg v: Verbose mode. Display column headers, default True """ _, data = self.transport.perform_request('GET', _make_path('_cat', 'shards', index), params=params) return data - @query_params('bytes', 'h', 'help', 'local', 'master_timeout', '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. - ``_ + ``_ :arg index: A comma-separated list of index names to limit the returned information - :arg bytes: The unit in which to display byte values :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 + :arg v: Verbose mode. Display column headers, default True """ _, data = self.transport.perform_request('GET', _make_path('_cat', 'segments', index), params=params) @@ -223,7 +217,7 @@ class CatClient(NamespacedClient): pending_tasks provides the same information as the :meth:`~elasticsearch.client.cluster.ClusterClient.pending_tasks` API in a convenient tabular format. - ``_ + ``_ :arg h: Comma-separated list of column names to display :arg help: Return help information, default False @@ -231,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 False + :arg v: Verbose mode. Display column headers, default True """ _, data = self.transport.perform_request('GET', '/_cat/pending_tasks', params=params) @@ -241,17 +235,16 @@ class CatClient(NamespacedClient): def thread_pool(self, params=None): """ Get information about thread pools. - ``_ + ``_ - :arg full_id: Enables displaying the complete node ids (default: 'false') + :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 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') - + :arg v: Verbose mode. Display column headers, default True """ _, data = self.transport.perform_request('GET', '/_cat/thread_pool', params=params) @@ -262,21 +255,20 @@ class CatClient(NamespacedClient): def fielddata(self, fields=None, params=None): """ Shows information about currently loaded fielddata on a per-node basis. - ``_ + ``_ :arg fields: A comma-separated list of fields to return the fielddata size - :arg bytes: The unit in which to display byte values - :arg fields: A comma-separated list of fields to return the fielddata - size + :arg bytes: The unit in which to display byte values, valid choices are: + 'b', 'k', 'm', 'g' + :arg fields: A comma-separated list of fields to return in the output :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 master node (default: false) :arg master_timeout: Explicit operation timeout for connection to master node - :arg v: Verbose mode. Display column headers (default: 'false') - + :arg v: Verbose mode. Display column headers, default True """ _, data = self.transport.perform_request('GET', _make_path('_cat', 'fielddata', fields), params=params) @@ -285,6 +277,7 @@ class CatClient(NamespacedClient): @query_params('h', 'help', 'local', 'master_timeout', 'v') def plugins(self, params=None): """ + ``_ :arg h: Comma-separated list of column names to display @@ -293,9 +286,26 @@ 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 False + :arg v: Verbose mode. Display column headers, default True """ _, data = self.transport.perform_request('GET', '/_cat/plugins', params=params) return data + @query_params('h', 'help', 'local', 'master_timeout', 'v') + def nodeattrs(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 True + """ + _, data = self.transport.perform_request('GET', '/_cat/nodeattrs', + params=params) + return data + diff --git a/elasticsearch/client/cluster.py b/elasticsearch/client/cluster.py index c51edba2..ca0aacf4 100644 --- a/elasticsearch/client/cluster.py +++ b/elasticsearch/client/cluster.py @@ -2,25 +2,32 @@ from .utils import NamespacedClient, query_params, _make_path class ClusterClient(NamespacedClient): @query_params('level', 'local', 'master_timeout', 'timeout', - 'wait_for_active_shards', 'wait_for_nodes', 'wait_for_relocating_shards', - 'wait_for_status') + 'wait_for_active_shards', 'wait_for_nodes', + 'wait_for_relocating_shards', 'wait_for_status') def health(self, index=None, params=None): """ Get a very simple status on the health of the cluster. ``_ :arg index: Limit the information returned to a specific index - :arg level: Specify the level of detail for returned information, default u'cluster' - :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 level: Specify the level of detail for returned information, + default 'cluster', valid choices are: 'cluster', 'indices', 'shards' + :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 timeout: Explicit operation timeout - :arg wait_for_active_shards: Wait until the specified number of shards is active - :arg wait_for_nodes: Wait until the specified number of nodes is available - :arg wait_for_relocating_shards: Wait until the specified number of relocating shards is finished - :arg wait_for_status: Wait until cluster is in a specific state, default None + :arg wait_for_active_shards: Wait until the specified number of shards + is active + :arg wait_for_nodes: Wait until the specified number of nodes is + available + :arg wait_for_relocating_shards: Wait until the specified number of + relocating shards is finished + :arg wait_for_status: Wait until cluster is in a specific state, default + None, valid choices are: 'green', 'yellow', 'red' """ - _, data = self.transport.perform_request('GET', _make_path('_cluster', 'health', index), - params=params) + _, data = self.transport.perform_request('GET', _make_path('_cluster', + 'health', index), params=params) return data @query_params('local', 'master_timeout') @@ -31,11 +38,12 @@ class ClusterClient(NamespacedClient): which have not yet been executed. ``_ - :arg local: Return local information, do not retrieve the state from master node (default: false) + :arg local: Return local information, do not retrieve the state from + master node (default: false) :arg master_timeout: Specify timeout for connection to master """ - _, data = self.transport.perform_request('GET', '/_cluster/pending_tasks', - params=params) + _, data = self.transport.perform_request('GET', + '/_cluster/pending_tasks', params=params) return data @query_params('allow_no_indices', 'expand_wildcards', 'flat_settings', @@ -45,16 +53,15 @@ class ClusterClient(NamespacedClient): Get a comprehensive state information of the whole cluster. ``_ - :arg metric: Limit the information returned to the specified metrics. - Possible values: "_all", "blocks", "index_templates", "metadata", - "nodes", "routing_table", "master_node", "version" + :arg metric: Limit the information returned to the specified metrics :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 wildcard expressions should get expanded - to open or closed indices (default: open) + :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 flat_settings: Return settings in flat format (default: false) :arg ignore_unavailable: Whether specified concrete indices should be ignored when unavailable (missing or closed) @@ -64,7 +71,8 @@ class ClusterClient(NamespacedClient): """ if index and not metric: metric = '_all' - _, data = self.transport.perform_request('GET', _make_path('_cluster', 'state', metric, index), params=params) + _, data = self.transport.perform_request('GET', _make_path('_cluster', + 'state', metric, index), params=params) return data @query_params('flat_settings', 'human') @@ -76,11 +84,12 @@ class ClusterClient(NamespacedClient): ``_ :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 + returned information; use `_local` to return information from the + node you're connecting to, leave empty to get information from all + nodes :arg flat_settings: Return settings in flat format (default: false) - :arg human: Whether to return time and byte values in human-readable format. - + :arg human: Whether to return time and byte values in human-readable + format., default False """ url = '/_cluster/stats' if node_id: @@ -94,16 +103,20 @@ class ClusterClient(NamespacedClient): Explicitly execute a cluster reroute allocation command including specific commands. ``_ - :arg body: The definition of `commands` to perform (`move`, `cancel`, `allocate`) + :arg body: The definition of `commands` to perform (`move`, `cancel`, + `allocate`) :arg dry_run: Simulate the operation only and return the resulting state - :arg explain: Return an explanation of why the commands can or cannot be executed - :arg filter_metadata: Don't return cluster state metadata (default: false) - :arg master_timeout: Explicit operation timeout for connection to master node + :arg explain: Return an explanation of why the commands can or cannot be + executed + :arg master_timeout: Explicit operation timeout for connection to master + node :arg metric: Limit the information returned to the specified metrics. - Defaults to all but metadata + Defaults to all but metadata, valid choices are: '_all', 'blocks', + 'metadata', 'nodes', 'routing_table', 'master_node', 'version' :arg timeout: Explicit operation timeout """ - _, data = self.transport.perform_request('POST', '/_cluster/reroute', params=params, body=body) + _, data = self.transport.perform_request('POST', '/_cluster/reroute', + params=params, body=body) return data @query_params('flat_settings', 'master_timeout', 'timeout') @@ -113,14 +126,16 @@ class ClusterClient(NamespacedClient): ``_ :arg flat_settings: Return settings in flat format (default: false) - :arg master_timeout: Explicit operation timeout for connection to master node + :arg master_timeout: Explicit operation timeout for connection to master + node :arg timeout: Explicit operation timeout """ - _, data = self.transport.perform_request('GET', '/_cluster/settings', params=params) + _, data = self.transport.perform_request('GET', '/_cluster/settings', + params=params) return data @query_params('flat_settings', 'master_timeout', 'timeout') - def put_settings(self, body, params=None): + def put_settings(self, body=None, params=None): """ Update cluster wide specific settings. ``_ @@ -132,6 +147,7 @@ class ClusterClient(NamespacedClient): node :arg timeout: Explicit operation timeout """ - _, data = self.transport.perform_request('PUT', '/_cluster/settings', params=params, body=body) + _, data = self.transport.perform_request('PUT', '/_cluster/settings', + params=params, body=body) return data diff --git a/elasticsearch/client/indices.py b/elasticsearch/client/indices.py index aba808f8..67fc3fec 100644 --- a/elasticsearch/client/indices.py +++ b/elasticsearch/client/indices.py @@ -3,7 +3,7 @@ from ..exceptions import NotFoundError class IndicesClient(NamespacedClient): @query_params('analyzer', 'char_filters', 'field', 'filters', 'format', - 'prefer_local', 'text', 'tokenizer') + '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. @@ -17,19 +17,21 @@ class IndicesClient(NamespacedClient): :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 - :arg format: Format of the output, default u'detailed' + :arg format: Format of the output, default 'detailed', valid choices + are: 'detailed', 'text' + :arg index: The name of the index to scope the operation :arg prefer_local: With `true`, specify that a local shard should be used if available, with `false`, use a random shard (default: true) :arg text: The text on which the analysis should be performed (when request body is not used) :arg tokenizer: The name of the tokenizer to use for the analysis """ - _, data = self.transport.perform_request('GET', _make_path(index, '_analyze'), - params=params, body=body) + _, data = self.transport.perform_request('GET', _make_path(index, + '_analyze'), params=params, body=body) return data - @query_params('allow_no_indices', 'expand_wildcards', 'ignore_indices', - 'ignore_unavailable', 'force') + @query_params('allow_no_indices', 'expand_wildcards', 'force', + 'ignore_unavailable', 'operation_threading') def refresh(self, index=None, params=None): """ Explicitly refresh one or more index, making all operations performed @@ -39,22 +41,22 @@ class IndicesClient(NamespacedClient): :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 force: Force a refresh even if not required + 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 force: Force a refresh even if not required, default False + :arg ignore_unavailable: Whether specified concrete indices should be + ignored when unavailable (missing or closed) + :arg operation_threading: TODO: ? """ - _, data = self.transport.perform_request('POST', _make_path(index, '_refresh'), - params=params) + _, data = self.transport.perform_request('POST', _make_path(index, + '_refresh'), params=params) return data - @query_params('allow_no_indices', 'expand_wildcards', 'force', 'full', - 'ignore_indices', 'ignore_unavailable', 'wait_if_ongoing') + @query_params('allow_no_indices', 'expand_wildcards', 'force', + 'ignore_unavailable', 'wait_if_ongoing') def flush(self, index=None, params=None): """ Explicitly flush one or more indices. @@ -62,30 +64,30 @@ 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 force: Whether a flush should be forced even if it is not necessarily needed ie. if no changes will be committed to the index. - :arg full: If set to true a new index writer is created and settings - that have been changed related to the index writer will be refreshed. - :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) + This is useful if transaction log IDs should be incremented even if + no uncommitted changes are present. (This setting can be considered + as internal) + :arg ignore_unavailable: Whether specified concrete indices should be + ignored when unavailable (missing or closed) :arg wait_if_ongoing: If set to true the flush operation will block until the flush can be executed if another flush operation is already executing. The default is false and will cause an exception to be thrown on the shard level if another flush operation is already running. """ - _, data = self.transport.perform_request('POST', _make_path(index, '_flush'), - params=params) + _, data = self.transport.perform_request('POST', _make_path(index, + '_flush'), params=params) return data - @query_params('timeout', 'master_timeout') + @query_params('master_timeout', 'timeout') def create(self, index, body=None, params=None): """ Create an index in Elasticsearch. @@ -114,7 +116,8 @@ class IndicesClient(NamespacedClient): :arg allow_no_indices: Ignore if a wildcard expression resolves to no concrete indices (default: false) :arg expand_wildcards: Whether wildcard expressions should get expanded - to open or closed indices (default: open) + to open or closed indices (default: open), default 'open', valid + choices are: 'open', 'closed', 'none', 'all' :arg flat_settings: Return settings in flat format (default: false) :arg human: Whether to return version and creation date values in human- readable format., default False @@ -128,28 +131,29 @@ class IndicesClient(NamespacedClient): feature), params=params) return data - @query_params('timeout', 'master_timeout' 'allow_no_indices', - 'expand_wildcards', 'ignore_unavailable') + @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', + 'master_timeout', 'timeout') def open(self, index, params=None): """ Open a closed index to make it available for search. ``_ :arg index: The name of the index + :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 'closed', valid + choices are: 'open', 'closed', 'none', 'all' + :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 - :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_unavailable: Whether specified concrete indices should be ignored - when unavailable (missing or closed) """ if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") - _, data = self.transport.perform_request('POST', _make_path(index, '_open'), - params=params) + _, data = self.transport.perform_request('POST', _make_path(index, + '_open'), params=params) return data @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', @@ -160,13 +164,13 @@ class IndicesClient(NamespacedClient): is blocked for read/write operations. ``_ - :arg index: A comma-separated list of indices to close; use `_all` or - '*' to close all indices + :arg index: The name of the index :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' + 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) :arg master_timeout: Specify timeout for connection to master @@ -174,18 +178,18 @@ class IndicesClient(NamespacedClient): """ if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") - _, data = self.transport.perform_request('POST', _make_path(index, '_close'), - params=params) + _, data = self.transport.perform_request('POST', _make_path(index, + '_close'), params=params) return data - @query_params('timeout', 'master_timeout') + @query_params('master_timeout', 'timeout') def delete(self, index, params=None): """ Delete an index in Elasticsearch ``_ :arg index: A comma-separated list of indices to delete; use `_all` or - '*' to delete all indices + `*` string to delete all indices :arg master_timeout: Specify timeout for connection to master :arg timeout: Explicit operation timeout """ @@ -202,12 +206,13 @@ class IndicesClient(NamespacedClient): Return a boolean indicating whether given index exists. ``_ - :arg index: A list of indices to check + :arg index: A comma-separated 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' + 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) :arg local: Return local information, do not retrieve the state from @@ -216,13 +221,14 @@ class IndicesClient(NamespacedClient): if index in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'index'.") try: - self.transport.perform_request('HEAD', _make_path(index), params=params) + self.transport.perform_request('HEAD', _make_path(index), + params=params) except NotFoundError: return False return True - @query_params('allow_no_indices', 'expand_wildcards', 'ignore_indices', - 'ignore_unavailable', 'local') + @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', + 'local') def exists_type(self, index, doc_type, params=None): """ Check if a type/types exists in an index/indices. @@ -232,14 +238,13 @@ class IndicesClient(NamespacedClient): the types across all indices :arg doc_type: A comma-separated list of document types 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. - :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) + 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) :arg local: Return local information, do not retrieve the state from master node (default: false) """ @@ -247,13 +252,14 @@ class IndicesClient(NamespacedClient): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") try: - self.transport.perform_request('HEAD', _make_path(index, doc_type), params=params) + self.transport.perform_request('HEAD', _make_path(index, doc_type), + params=params) except NotFoundError: return False return True - @query_params('allow_no_indices', 'expand_wildcards', 'ignore_conflicts', - 'ignore_unavailable', 'master_timeout', 'timeout') + @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', + 'master_timeout', 'timeout') def put_mapping(self, doc_type, body, index=None, params=None): """ Register specific mapping definition for a specific type. @@ -261,16 +267,15 @@ class IndicesClient(NamespacedClient): :arg doc_type: The name of the document type :arg body: The mapping definition - :arg index: A list of index names the mapping should be added to - (supports wildcards); use `_all` or omit to add the mapping on all - indices. + :arg index: A comma-separated list of index names the mapping should be + added to (supports wildcards); use `_all` or omit to add the mapping + 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., default u'open' - :arg ignore_conflicts: Specify whether to ignore conflicts while - updating the mapping (default: false) + 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) :arg master_timeout: Specify timeout for connection to master @@ -279,60 +284,61 @@ class IndicesClient(NamespacedClient): for param in (doc_type, body): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - _, data = self.transport.perform_request('PUT', _make_path(index, '_mapping', doc_type), - params=params, body=body) + _, data = self.transport.perform_request('PUT', _make_path(index, + '_mapping', doc_type), params=params, body=body) return data - @query_params('ignore_unavailable', 'allow_no_indices', 'expand_wildcards', + @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', 'local') def get_mapping(self, index=None, doc_type=None, params=None): """ Retrieve mapping definition of index or index/type. ``_ - :arg index: A comma-separated list of index names; use `_all` or empty - string for all indices + :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 - 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_unavailable: Whether specified concrete indices should be ignored - when unavailable (missing or closed) + 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) :arg local: Return local information, do not retrieve the state from master node (default: false) """ - _, data = self.transport.perform_request('GET', _make_path(index, '_mapping', doc_type), - params=params) + _, data = self.transport.perform_request('GET', _make_path(index, + '_mapping', doc_type), params=params) return data - @query_params("include_defaults", 'ignore_unavailable', 'allow_no_indices', - 'expand_wildcards', 'local') + @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): """ Retrieve mapping definition of a specific field. ``_ - :arg index: A comma-separated list of index names; use `_all` or empty - string for all indices + :arg field: 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 field: A comma-separated list of fields to retrieve the mapping for - :arg include_defaults: A boolean indicating whether to return default values :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_unavailable: Whether specified concrete indices should be ignored - when unavailable (missing or closed) + 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) + :arg include_defaults: Whether the default mapping values should be + returned as well :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'.") - _, data = self.transport.perform_request('GET', _make_path(index, '_mapping', doc_type, 'field', field), - params=params) + _, data = self.transport.perform_request('GET', _make_path(index, + '_mapping', doc_type, 'field', field), params=params) return data @query_params('master_timeout') @@ -354,16 +360,15 @@ class IndicesClient(NamespacedClient): _, data = self.transport.perform_request('DELETE', _make_path(index, '_mapping', doc_type), params=params) return data - - @query_params('timeout', 'master_timeout') - def put_alias(self, name, index, body=None, params=None): + @query_params('master_timeout', 'timeout') + def put_alias(self, index, name, body=None, params=None): """ Create an alias for a specific index/indices. ``_ - :arg index: A comma-separated list of index names the alias should - point to (supports wildcards); use `_all` or omit to perform the - operation on all indices. + :arg index: A comma-separated list of index names the alias should point + to (supports wildcards); use `_all` to perform the operation on all + indices. :arg name: The name of the alias to be created or updated :arg body: The settings for the alias, such as `routing` or `filter` :arg master_timeout: Specify timeout for connection to master @@ -372,60 +377,59 @@ class IndicesClient(NamespacedClient): for param in (index, name): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - _, data = self.transport.perform_request('PUT', _make_path(index, '_alias', name), - params=params, body=body) + _, data = self.transport.perform_request('PUT', _make_path(index, + '_alias', name), params=params, body=body) return data - @query_params('allow_no_indices', 'expand_wildcards', 'ignore_indices', 'ignore_unavailable', + @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', 'local') - def exists_alias(self, name, index=None, params=None): + def exists_alias(self, index=None, name=None, params=None): """ Return a boolean indicating whether given alias exists. ``_ - :arg name: A comma-separated list of alias names to return :arg index: A comma-separated list of index names to filter aliases + :arg name: A comma-separated list of alias names to return :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) + 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', 'closed'], + valid choices are: 'open', 'closed', 'none', 'all' + :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) """ try: - self.transport.perform_request('HEAD', _make_path(index, '_alias', name), - params=params) + self.transport.perform_request('HEAD', _make_path(index, '_alias', + name), params=params) except NotFoundError: return False return True - @query_params('allow_no_indices', 'expand_wildcards', 'ignore_indices', 'ignore_unavailable', 'local') + @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', + 'local') def get_alias(self, index=None, name=None, params=None): """ Retrieve a specified alias. ``_ - :arg name: A comma-separated list of alias names to return :arg index: A comma-separated list of index names to filter aliases + :arg name: A comma-separated list of alias names to return :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) + 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) :arg local: Return local information, do not retrieve the state from master node (default: false) """ - _, data = self.transport.perform_request('GET', _make_path(index, '_alias', name), - params=params) + _, data = self.transport.perform_request('GET', _make_path(index, + '_alias', name), params=params) return data @query_params('local', 'timeout') @@ -440,11 +444,11 @@ class IndicesClient(NamespacedClient): master node (default: false) :arg timeout: Explicit operation timeout """ - _, data = self.transport.perform_request('GET', _make_path(index, '_aliases', name), - params=params) + _, data = self.transport.perform_request('GET', _make_path(index, + '_aliases', name), params=params) return data - @query_params('timeout', 'master_timeout') + @query_params('master_timeout', 'timeout') def update_aliases(self, body, params=None): """ Update specified aliases. @@ -460,7 +464,7 @@ class IndicesClient(NamespacedClient): params=params, body=body) return data - @query_params('timeout', 'master_timeout') + @query_params('master_timeout', 'timeout') def delete_alias(self, index, name, params=None): """ Delete specific alias. @@ -469,18 +473,20 @@ class IndicesClient(NamespacedClient): :arg index: A comma-separated list of index names (supports wildcards); use `_all` for all indices :arg name: A comma-separated list of aliases to delete (supports - wildcards); use `_all` to delete all aliases for the specified indices. + wildcards); use `_all` to delete all aliases for the specified + indices. :arg master_timeout: Specify timeout for connection to master :arg timeout: Explicit timestamp for the document """ for param in (index, name): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - _, data = self.transport.perform_request('DELETE', _make_path(index, '_alias', name), - params=params) + _, data = self.transport.perform_request('DELETE', _make_path(index, + '_alias', name), params=params) return data - @query_params('create', 'order', 'timeout', 'master_timeout', 'flat_settings') + @query_params('create', 'flat_settings', 'master_timeout', 'order', + 'timeout') def put_template(self, name, body, params=None): """ Create an index template that will automatically be applied to new @@ -490,18 +496,18 @@ class IndicesClient(NamespacedClient): :arg name: The name of the template :arg body: The template definition :arg create: Whether the index template should only be added if new or - can also replace an existing one + can also replace an existing one, default False + :arg flat_settings: Return settings in flat format (default: false) + :arg master_timeout: Specify timeout for connection to master :arg order: The order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers) - :arg master_timeout: Specify timeout for connection to master :arg timeout: Explicit operation timeout - :arg flat_settings: Return settings in flat format (default: false) """ for param in (name, body): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - _, data = self.transport.perform_request('PUT', _make_path('_template', name), - params=params, body=body) + _, data = self.transport.perform_request('PUT', _make_path('_template', + name), params=params, body=body) return data @query_params('local', 'master_timeout') @@ -519,8 +525,8 @@ class IndicesClient(NamespacedClient): if name in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'name'.") try: - self.transport.perform_request('HEAD', _make_path('_template', name), - params=params) + self.transport.perform_request('HEAD', _make_path('_template', + name), params=params) except NotFoundError: return False return True @@ -538,11 +544,11 @@ class IndicesClient(NamespacedClient): :arg master_timeout: Explicit operation timeout for connection to master node """ - _, data = self.transport.perform_request('GET', _make_path('_template', name), - params=params) + _, data = self.transport.perform_request('GET', _make_path('_template', + name), params=params) return data - @query_params('timeout', 'master_timeout') + @query_params('master_timeout', 'timeout') def delete_template(self, name, params=None): """ Delete an index template by its name. @@ -554,12 +560,12 @@ class IndicesClient(NamespacedClient): """ if name in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'name'.") - _, data = self.transport.perform_request('DELETE', _make_path('_template', name), - params=params) + _, data = self.transport.perform_request('DELETE', + _make_path('_template', name), params=params) return data - @query_params('expand_wildcards', 'ignore_indices', 'ignore_unavailable', - 'flat_settings', 'local', 'human') + @query_params('allow_no_indices', 'expand_wildcards', 'flat_settings', + 'human', 'ignore_unavailable', 'local') def get_settings(self, index=None, name=None, params=None): """ Retrieve settings for one or more (or all) indices. @@ -568,20 +574,22 @@ class IndicesClient(NamespacedClient): :arg index: A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices :arg name: The name of the settings that should be included - :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 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', 'closed'], + valid choices are: 'open', 'closed', 'none', 'all' :arg flat_settings: Return settings in flat format (default: false) :arg human: Whether to return version and creation date values in human- readable format., default False + :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) """ - _, data = self.transport.perform_request('GET', _make_path(index, '_settings', name), - params=params) + _, data = self.transport.perform_request('GET', _make_path(index, + '_settings', name), params=params) return data @query_params('allow_no_indices', 'expand_wildcards', 'flat_settings', @@ -598,7 +606,8 @@ 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 u'open' + indices that are open, closed or both., default 'open', valid + choices are: 'open', 'closed', 'none', 'all' :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) @@ -606,12 +615,12 @@ class IndicesClient(NamespacedClient): """ if body in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'body'.") - _, data = self.transport.perform_request('PUT', _make_path(index, '_settings'), - params=params, body=body) + _, data = self.transport.perform_request('PUT', _make_path(index, + '_settings'), params=params, body=body) return data @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', - 'master_timeout') + 'master_timeout', 'request_cache') 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 @@ -631,19 +640,20 @@ class IndicesClient(NamespacedClient): 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' + warm., default 'open', valid choices are: 'open', 'closed', 'none', + 'all' :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 + :arg request_cache: Specify whether the request to be wamred shoyd use + the request cache, defaults to index level setting """ for param in (name, body): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - if doc_type and not index: - index = '_all' - _, data = self.transport.perform_request('PUT', _make_path(index, doc_type, '_warmer', name), - params=params, body=body) + _, data = self.transport.perform_request('PUT', _make_path(index, + doc_type, '_warmer', name), params=params, body=body) return data @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', @@ -663,13 +673,15 @@ 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 u'open' + 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) :arg local: Return local information, do not retrieve the state from master node (default: false) """ - _, data = self.transport.perform_request('GET', _make_path(index, doc_type, '_warmer', name), params=params) + _, data = self.transport.perform_request('GET', _make_path(index, + doc_type, '_warmer', name), params=params) return data @query_params('master_timeout') @@ -679,16 +691,19 @@ class IndicesClient(NamespacedClient): ``_ :arg index: A comma-separated list of index names to delete warmers from - (supports wildcards); use `_all` to perform the operation on all indices. + (supports wildcards); use `_all` to perform the operation on all + indices. :arg name: A comma-separated list of warmer names to delete (supports - wildcards); use `_all` to delete all warmers in the specified indices. + wildcards); use `_all` to delete all warmers in the specified + indices. You must specify a name either in the uri or in the + parameters. :arg master_timeout: Specify timeout for connection to master """ for param in (index, name): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") - _, data = self.transport.perform_request('DELETE', _make_path(index, '_warmer', name), - params=params) + _, data = self.transport.perform_request('DELETE', _make_path(index, + '_warmer', name), params=params) return data @query_params('allow_no_indices', 'expand_wildcards', 'ignore_indices', @@ -718,9 +733,8 @@ class IndicesClient(NamespacedClient): params=params) return data - @query_params('completion_fields', 'docs', 'fielddata_fields', 'fields', 'groups', - 'allow_no_indices', 'expand_wildcards', 'ignore_indices', - 'ignore_unavailable', 'human', 'level', 'types') + @query_params('completion_fields', 'fielddata_fields', 'fields', 'groups', + 'human', 'level', 'types') def stats(self, index=None, metric=None, params=None): """ Retrieve statistics on different operations happening on an index. @@ -728,38 +742,28 @@ class IndicesClient(NamespacedClient): :arg index: A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - :arg metric: A comma-separated list of metrics to display. Possible - values: "_all", "completion", "docs", "fielddata", "filter_cache", - "flush", "get", "id_cache", "indexing", "merge", "percolate", - "refresh", "search", "segments", "store", "warmer" - :arg completion_fields: A comma-separated list of fields for - `completion` metric (supports wildcards) + :arg metric: Limit the information returned the specific metrics. + :arg completion_fields: A comma-separated list of fields for `fielddata` + and `suggest` index metric (supports wildcards) :arg fielddata_fields: A comma-separated list of fields for `fielddata` - metric (supports wildcards) + index metric (supports wildcards) :arg fields: A comma-separated list of fields for `fielddata` and - `completion` metric (supports wildcards) - :arg groups: A comma-separated list of search groups for `search` statistics - :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) - :arg human: Whether to return time and byte values in human-readable format. - :arg level: Return stats aggregated at cluster, index or shard level. - ("cluster", "indices" or "shards", default: "indices") + `completion` index metric (supports wildcards) + :arg groups: A comma-separated list of search groups for `search` index + metric + :arg human: Whether to return time and byte values in human-readable + format., default False + :arg level: Return stats aggregated at cluster, index or shard level, + default 'indices', valid choices are: 'cluster', 'indices', 'shards' :arg types: A comma-separated list of document types for the `indexing` index metric """ - _, data = self.transport.perform_request('GET', _make_path(index, '_stats', metric), - params=params) + _, data = self.transport.perform_request('GET', _make_path(index, + '_stats', metric), params=params) return data - @query_params('allow_no_indices', 'expand_wildcards', 'ignore_indices', - 'ignore_unavailable', 'human') + @query_params('allow_no_indices', 'expand_wildcards', 'human', + 'ignore_unavailable', 'operation_threading') def segments(self, index=None, params=None): """ Provide low level segments information that a Lucene index (shard level) is built with. @@ -768,23 +772,24 @@ class IndicesClient(NamespacedClient): :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) + 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 human: Whether to return time and byte values in human-readable - format (default: false) + format., default False + :arg ignore_unavailable: Whether specified concrete indices should be + ignored when unavailable (missing or closed) + :arg operation_threading: TODO: ? """ - _, data = self.transport.perform_request('GET', _make_path(index, '_segments'), params=params) + _, data = self.transport.perform_request('GET', _make_path(index, + '_segments'), params=params) return data - @query_params('flush', 'allow_no_indices', 'expand_wildcards', - 'ignore_indices', 'ignore_unavailable', 'max_num_segments', - 'only_expunge_deletes', 'operation_threading', 'wait_for_merge') + @query_params('allow_no_indices', 'expand_wildcards', 'flush', + 'ignore_unavailable', 'max_num_segments', 'only_expunge_deletes', + 'operation_threading', 'wait_for_merge') def optimize(self, index=None, params=None): """ Explicitly optimize one or more indices through an API. @@ -792,32 +797,32 @@ class IndicesClient(NamespacedClient): :arg index: A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - :arg flush: Specify whether the index should be flushed after - performing the operation (default: true) :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 max_num_segments: The number of segments the index should be - merged into (default: dynamic) + 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 flush: Specify whether the index should be flushed after performing + the operation (default: true) + :arg ignore_unavailable: Whether specified concrete indices should be + ignored when unavailable (missing or closed) + :arg max_num_segments: The number of segments the index should be merged + into (default: dynamic) :arg only_expunge_deletes: Specify whether the operation should only expunge deleted documents :arg operation_threading: TODO: ? :arg wait_for_merge: Specify whether the request should block until the merge process is finished (default: true) """ - _, data = self.transport.perform_request('POST', _make_path(index, '_optimize'), params=params) + _, data = self.transport.perform_request('POST', _make_path(index, + '_optimize'), params=params) return data @query_params('allow_no_indices', 'analyze_wildcard', 'analyzer', 'default_operator', 'df', 'expand_wildcards', 'explain', 'ignore_unavailable', 'lenient', 'lowercase_expanded_terms', - 'operation_threading', 'q') + 'operation_threading', 'q', 'rewrite') def validate_query(self, index=None, doc_type=None, body=None, params=None): """ Validate a potentially expensive query without executing it. @@ -836,11 +841,12 @@ class IndicesClient(NamespacedClient): should be analyzed (default: false) :arg analyzer: The analyzer to use for the query string :arg default_operator: The default operator for query string query (AND - or OR), default u'OR' + or OR), default 'OR', valid choices are: 'AND', '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' + indices that are open, closed or both., default 'open', valid + choices are: 'open', 'closed', 'none', 'all' :arg explain: Return detailed information about the error :arg ignore_unavailable: Whether specified concrete indices should be ignored when unavailable (missing or closed) @@ -850,44 +856,41 @@ class IndicesClient(NamespacedClient): lowercased :arg operation_threading: TODO: ? :arg q: Query in the Lucene query string syntax + :arg rewrite: Provide a more detailed explanation showing the actual + Lucene query that will be executed. """ - _, data = self.transport.perform_request('GET', _make_path(index, doc_type, '_validate', 'query'), - params=params, body=body) + _, data = self.transport.perform_request('GET', _make_path(index, + doc_type, '_validate', 'query'), params=params, body=body) return data - @query_params('field_data', 'fielddata', 'fields', 'filter', 'filter_cache', - 'filter_keys', 'id', 'id_cache', 'allow_no_indices', 'expand_wildcards', - 'ignore_indices', 'ignore_unavailable', 'query_cache', 'recycler') + @query_params('allow_no_indices', 'expand_wildcards', 'field_data', + 'fielddata', 'fields', 'ignore_unavailable', 'index', 'query', + 'recycler', 'request') def clear_cache(self, index=None, params=None): """ Clear either all caches or specific cached associated with one ore more indices. ``_ :arg index: A comma-separated list of index name to limit the operation + :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 field_data: Clear field data :arg fielddata: Clear field data :arg fields: A comma-separated list of fields to clear when using the `field_data` parameter (default: all) - :arg filter: Clear filter caches - :arg filter_cache: Clear filter caches - :arg filter_keys: A comma-separated list of keys to clear when using - the `filter_cache` parameter (default: all) - :arg id: Clear ID caches for parent/child - :arg id_cache: Clear ID caches for parent/child - :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) - :arg query_cache: Clear query cache + :arg ignore_unavailable: Whether specified concrete indices should be + ignored when unavailable (missing or closed) + :arg index: A comma-separated list of index name to limit the operation + :arg query: Clear query caches :arg recycler: Clear the recycler cache + :arg request: Clear request cache """ - _, data = self.transport.perform_request('POST', _make_path(index, '_cache', 'clear'), - params=params) + _, data = self.transport.perform_request('POST', _make_path(index, + '_cache', 'clear'), params=params) return data @query_params('active_only', 'detailed', 'human') @@ -896,17 +899,16 @@ class IndicesClient(NamespacedClient): The indices recovery API provides insight into on-going shard recoveries. Recovery status may be reported for specific indices, or cluster-wide. - ``_ + ``_ :arg index: A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices :arg active_only: Display only those recoveries that are currently on- - going (default: 'false') + going, default False :arg detailed: Whether to display detailed information about shard - recovery (default: 'false') + recovery, default False :arg human: Whether to return time and byte values in human-readable - format. (default: 'false') - + format., default False """ _, data = self.transport.perform_request('GET', _make_path(index, '_recovery'), params=params) @@ -925,13 +927,14 @@ 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 u'open' + 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) :arg only_ancient_segments: If true, only ancient (an older Lucene major release) segments will be upgraded :arg wait_for_completion: Specify whether the request should block until - the all segments are upgraded (default: true) + the all segments are upgraded (default: false) """ _, data = self.transport.perform_request('POST', _make_path(index, '_upgrade'), params=params) @@ -950,7 +953,8 @@ 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 u'open' + indices that are open, closed or both., default 'open', valid + choices are: 'open', 'closed', 'none', 'all' :arg human: Whether to return time and byte values in human-readable format., default False :arg ignore_unavailable: Whether specified concrete indices should be @@ -964,7 +968,7 @@ class IndicesClient(NamespacedClient): def flush_synced(self, index=None, params=None): """ Perform a normal flush, then add a generated unique marker (sync_id) to all shards. - ``_ + ``_ :arg index: A comma-separated list of index names; use `_all` or empty string for all indices @@ -973,3 +977,28 @@ class IndicesClient(NamespacedClient): '_flush', 'synced'), params=params) return data + @query_params('allow_no_indices', 'expand_wildcards', 'ignore_unavailable', + 'operation_threading', 'status') + def shard_stores(self, index=None, params=None): + """ + ``_ + + :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., default 'open', valid + choices are: 'open', 'closed', 'none', 'all' + :arg ignore_unavailable: Whether specified concrete indices should be + ignored when unavailable (missing or closed) + :arg operation_threading: TODO: ? + :arg status: A comma-separated list of statuses used to filter on shards + to get store information for, valid choices are: 'green', 'yellow', + 'red', 'all' + """ + _, data = self.transport.perform_request('GET', _make_path(index, + '_shard_stores'), params=params) + return data + diff --git a/elasticsearch/client/nodes.py b/elasticsearch/client/nodes.py index feb25663..13320490 100644 --- a/elasticsearch/client/nodes.py +++ b/elasticsearch/client/nodes.py @@ -13,16 +13,15 @@ class NodesClient(NamespacedClient): node you're connecting to, leave empty to get information from all nodes :arg metric: A comma-separated list of metrics you wish returned. Leave - empty to return all. Choices are "settings", "os", "process", - "jvm", "thread_pool", "network", "transport", "http", "plugin" + empty to return all. :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 + format., default False """ _, 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): """ @@ -53,15 +52,10 @@ class NodesClient(NamespacedClient): returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - :arg metric: Limit the information returned to the specified metrics. - Possible options are: "_all", "breaker", "fs", "http", "indices", - "jvm", "network", "os", "process", "thread_pool", "transport" + :arg metric: Limit the information returned to the specified metrics :arg index_metric: Limit the information returned for `indices` metric to the specific index metrics. Isn't used if `indices` (or `all`) - metric isn't specified. Possible options are: "_all", "completion", - "docs", "fielddata", "filter_cache", "flush", "get", "id_cache", - "indexing", "merge", "percolate", "refresh", "search", "segments", - "store", "warmer" + metric isn't specified. :arg completion_fields: A comma-separated list of fields for `fielddata` and `suggest` index metric (supports wildcards) :arg fielddata_fields: A comma-separated list of fields for `fielddata` @@ -73,15 +67,16 @@ class NodesClient(NamespacedClient): :arg human: Whether to return time and byte values in human-readable format., default False :arg level: Return indices stats aggregated at node, index or shard - level, default 'node' + level, default 'node', valid choices are: 'node', 'indices', + 'shards' :arg types: A comma-separated list of document types for the `indexing` - index metric + index metric """ _, data = self.transport.perform_request('GET', _make_path('_nodes', node_id, 'stats', metric, index_metric), params=params) return data - - @query_params('type_', 'ignore_idle_threads', 'interval', 'snapshots', + + @query_params('doc_type', 'ignore_idle_threads', 'interval', 'snapshots', 'threads') def hot_threads(self, node_id=None, params=None): """ @@ -92,20 +87,20 @@ class NodesClient(NamespacedClient): returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - :arg type_: The type to sample (default: cpu) + :arg doc_type: The type to sample (default: cpu), valid choices are: + 'cpu', 'wait', 'block' :arg ignore_idle_threads: Don't show threads that are in known-idle places, such as waiting on a socket select or pulling from an empty task queue (default: true) :arg interval: The interval for the second sampling of threads :arg snapshots: Number of samples of thread stacktrace (default: 10) :arg threads: Specify the number of threads to provide information for - (default: 3) + (default: 3) """ # avoid python reserved words if params and 'type_' in params: params['type'] = params.pop('type_') - _, data = self.transport.perform_request('GET', _make_path('_nodes', - node_id, 'hot_threads'), params=params) + _, data = self.transport.perform_request('GET', _make_path('_cluster', + 'nodes', node_id, 'hotthreads'), params=params) return data - diff --git a/elasticsearch/client/snapshot.py b/elasticsearch/client/snapshot.py index 477264a3..321580e0 100644 --- a/elasticsearch/client/snapshot.py +++ b/elasticsearch/client/snapshot.py @@ -5,7 +5,7 @@ class SnapshotClient(NamespacedClient): def create(self, repository, snapshot, body=None, params=None): """ Create a snapshot in repository - ``_ + ``_ :arg repository: A repository name :arg snapshot: A snapshot name @@ -13,7 +13,7 @@ class SnapshotClient(NamespacedClient): :arg master_timeout: Explicit operation timeout for connection to master node :arg wait_for_completion: Should this request wait until the operation - has completed before returning, default False + has completed before returning, default False """ for param in (repository, snapshot): if param in SKIP_IN_PATH: @@ -21,17 +21,17 @@ class SnapshotClient(NamespacedClient): _, data = self.transport.perform_request('PUT', _make_path('_snapshot', repository, snapshot), params=params, body=body) return data - + @query_params('master_timeout') def delete(self, repository, snapshot, params=None): """ Deletes a snapshot from a repository. - ``_ + ``_ :arg repository: A repository name :arg snapshot: A snapshot name :arg master_timeout: Explicit operation timeout for connection to master - node + node """ for param in (repository, snapshot): if param in SKIP_IN_PATH: @@ -39,17 +39,17 @@ class SnapshotClient(NamespacedClient): _, data = self.transport.perform_request('DELETE', _make_path('_snapshot', repository, snapshot), params=params) return data - + @query_params('master_timeout') def get(self, repository, snapshot, params=None): """ Retrieve information about a snapshot. - ``_ + ``_ - :arg repository: A comma-separated list of repository names + :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 + node """ for param in (repository, snapshot): if param in SKIP_IN_PATH: @@ -57,51 +57,52 @@ class SnapshotClient(NamespacedClient): _, data = self.transport.perform_request('GET', _make_path('_snapshot', repository, snapshot), params=params) return data - + @query_params('master_timeout', 'timeout') def delete_repository(self, repository, params=None): """ Removes a shared file system repository. - ``_ + ``_ :arg repository: A comma-separated list of repository names :arg master_timeout: Explicit operation timeout for connection to master node - :arg timeout: Explicit operation timeout + :arg timeout: Explicit operation timeout """ if repository in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument 'repository'.") _, data = self.transport.perform_request('DELETE', _make_path('_snapshot', repository), params=params) return data - + @query_params('local', 'master_timeout') def get_repository(self, repository=None, params=None): """ Return information about registered repositories. - ``_ + ``_ :arg repository: A comma-separated list of repository names - :arg master_timeout: Explicit operation timeout for connection to master - node :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 """ _, data = self.transport.perform_request('GET', _make_path('_snapshot', repository), params=params) return data - - @query_params('master_timeout', 'timeout') + + @query_params('master_timeout', 'timeout', 'verify') def create_repository(self, repository, body, params=None): """ Registers a shared file system repository. - ``_ + ``_ :arg repository: A repository name :arg body: The repository definition :arg master_timeout: Explicit operation timeout for connection to master node - :arg timeout: Explicit operation timeout + :arg timeout: Explicit operation timeout + :arg verify: Whether to verify the repository after creation """ for param in (repository, body): if param in SKIP_IN_PATH: @@ -109,12 +110,12 @@ class SnapshotClient(NamespacedClient): _, data = self.transport.perform_request('PUT', _make_path('_snapshot', repository), params=params, body=body) return data - + @query_params('master_timeout', 'wait_for_completion') def restore(self, repository, snapshot, body=None, params=None): """ Restore a snapshot. - ``_ + ``_ :arg repository: A repository name :arg snapshot: A snapshot name @@ -122,7 +123,7 @@ class SnapshotClient(NamespacedClient): :arg master_timeout: Explicit operation timeout for connection to master node :arg wait_for_completion: Should this request wait until the operation - has completed before returning, default False + has completed before returning, default False """ for param in (repository, snapshot): if param in SKIP_IN_PATH: diff --git a/test_elasticsearch/test_server/test_helpers.py b/test_elasticsearch/test_server/test_helpers.py index 0caaf948..2ff670eb 100644 --- a/test_elasticsearch/test_server/test_helpers.py +++ b/test_elasticsearch/test_server/test_helpers.py @@ -145,7 +145,8 @@ class TestBulk(ElasticsearchTestCase): self.assertEquals('42', error['index']['_id']) self.assertEquals('t', error['index']['_type']) self.assertEquals('i', error['index']['_index']) - self.assertIn('MapperParsingException', error['index']['error']) + print(error['index']['error']) + self.assertTrue('MapperParsingException' in repr(error['index']['error']) or 'mapper_parsing_exception' in repr(error['index']['error'])) def test_error_is_raised(self): self.client.indices.create("i",