2.0 compatibility
This commit is contained in:
+232
-176
@@ -184,10 +184,11 @@ class Elasticsearch(object):
|
||||
def ping(self, params=None):
|
||||
"""
|
||||
Returns True if the cluster is up, False otherwise.
|
||||
`<http://www.elastic.co/guide/>`_
|
||||
"""
|
||||
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.
|
||||
`<http://www.elastic.co/guide/>`_
|
||||
"""
|
||||
_, 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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html>`_
|
||||
|
||||
: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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html>`_
|
||||
|
||||
: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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html>`_
|
||||
|
||||
: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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.html>`_
|
||||
|
||||
: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 <field>:<direction> 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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/master/search-shards.html>`_
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-shards.html>`_
|
||||
|
||||
: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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/master/query-dsl-template-query.html>`_
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html>`_
|
||||
|
||||
: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):
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html>`_
|
||||
|
||||
: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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html>`_
|
||||
|
||||
: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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html>`_
|
||||
|
||||
See the :func:`~elasticsearch.helpers.bulk` helper function for a more
|
||||
friendly API.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html>`_
|
||||
|
||||
: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):
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html>`_
|
||||
|
||||
: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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html>`_
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters.html>`_
|
||||
|
||||
: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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-percolate.html>`_
|
||||
|
||||
: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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-termvectors.html>`
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-termvectors.html>`_
|
||||
|
||||
: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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-multi-termvectors.html>`_
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-termvectors.html>`_
|
||||
|
||||
: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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/master/search-field-stats.html>`_
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-field-stats.html>`_
|
||||
|
||||
: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):
|
||||
"""
|
||||
`<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-template.html>`_
|
||||
|
||||
: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
|
||||
|
||||
|
||||
+63
-53
@@ -4,7 +4,8 @@ class CatClient(NamespacedClient):
|
||||
@query_params('h', 'help', 'local', 'master_timeout', 'v')
|
||||
def aliases(self, name=None, params=None):
|
||||
"""
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-alias.html>`_
|
||||
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-alias.html>`_
|
||||
|
||||
: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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-allocation.html>`_
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-allocation.html>`_
|
||||
|
||||
: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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-count.html>`_
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-count.html>`_
|
||||
|
||||
: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
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-health.html>`_
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-health.html>`_
|
||||
|
||||
: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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/master/cat.html>`_
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/cat.html>`_
|
||||
|
||||
: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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-indices.html>`_
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-indices.html>`_
|
||||
|
||||
: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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-master.html>`_
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-master.html>`_
|
||||
|
||||
: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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodes.html>`_
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-nodes.html>`_
|
||||
|
||||
: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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-recovery.html>`_
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-recovery.html>`_
|
||||
|
||||
: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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-shards.html>`_
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-shards.html>`_
|
||||
|
||||
: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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-segments.html>`_
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-segments.html>`_
|
||||
|
||||
: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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-pending-tasks.html>`_
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-pending-tasks.html>`_
|
||||
|
||||
: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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-thread-pool.html>`_
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-thread-pool.html>`_
|
||||
|
||||
:arg full_id: Enables displaying the complete node ids (default: 'false')
|
||||
:arg 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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-fielddata.html>`_
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-fielddata.html>`_
|
||||
|
||||
: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):
|
||||
"""
|
||||
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-plugins.html>`_
|
||||
|
||||
: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):
|
||||
"""
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-nodeattrs.html>`_
|
||||
|
||||
: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
|
||||
|
||||
|
||||
@@ -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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html>`_
|
||||
|
||||
: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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-pending.html>`_
|
||||
|
||||
: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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-state.html>`_
|
||||
|
||||
: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):
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-stats.html>`_
|
||||
|
||||
: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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-reroute.html>`_
|
||||
|
||||
: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):
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-update-settings.html>`_
|
||||
|
||||
: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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-update-settings.html>`_
|
||||
@@ -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
|
||||
|
||||
|
||||
+297
-268
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ class SnapshotClient(NamespacedClient):
|
||||
def create(self, repository, snapshot, body=None, params=None):
|
||||
"""
|
||||
Create a snapshot in repository
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html>`_
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html>`_
|
||||
|
||||
: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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html>`_
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html>`_
|
||||
|
||||
: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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html>`_
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html>`_
|
||||
|
||||
: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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html>`_
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html>`_
|
||||
|
||||
: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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html>`_
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html>`_
|
||||
|
||||
: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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html>`_
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html>`_
|
||||
|
||||
: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.
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html>`_
|
||||
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html>`_
|
||||
|
||||
: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:
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user