diff --git a/elasticsearch/client/__init__.py b/elasticsearch/client/__init__.py
index 5f60581d..cd87af0e 100644
--- a/elasticsearch/client/__init__.py
+++ b/elasticsearch/client/__init__.py
@@ -30,6 +30,9 @@ from .security import SecurityClient
from .sql import SqlClient
from .ssl import SslClient
from .watcher import WatcherClient
+from .enrich import EnrichClient
+from .slm import SlmClient
+from .transform import TransformClient
logger = logging.getLogger("elasticsearch")
@@ -248,6 +251,9 @@ class Elasticsearch(object):
self.sql = SqlClient(self)
self.ssl = SslClient(self)
self.watcher = WatcherClient(self)
+ self.enrich = EnrichClient(self)
+ self.slm = SlmClient(self)
+ self.transform = TransformClient(self)
def __repr__(self):
try:
@@ -277,8 +283,9 @@ class Elasticsearch(object):
@query_params()
def ping(self, params=None):
"""
- Returns True if the cluster is up, False otherwise.
- ``_
+ Returns whether the cluster is running.
+ ``_
+
"""
try:
return self.transport.perform_request("HEAD", "/", params=params)
@@ -288,122 +295,466 @@ class Elasticsearch(object):
@query_params()
def info(self, params=None):
"""
- Get the basic info from the current cluster.
- ``_
+ Returns basic information about the cluster.
+ ``_
+
"""
return self.transport.perform_request("GET", "/", params=params)
@query_params(
- "parent",
"pipeline",
"refresh",
"routing",
"timeout",
- "timestamp",
- "ttl",
"version",
"version_type",
"wait_for_active_shards",
)
- def create(self, index, id, body, doc_type="_doc", params=None):
+ def create(self, index, id, body, doc_type=None, params=None):
"""
- Adds a typed JSON document in a specific index, making it searchable.
- Behind the scenes this method calls index(..., op_type='create')
- ``_
+ Creates a new document in the index. Returns a 409 response when a document
+ with a same ID already exists in the index.
+ ``_
:arg index: The name of the index
:arg id: Document ID
:arg body: The document
- :arg parent: ID of the parent document
- :arg pipeline: The pipeline id to preprocess incoming documents with
- :arg refresh: If `true` then refresh the affected shards to make this
- operation visible to search, if `wait_for` then wait for a refresh
- to make this operation visible to search, if `false` (the default)
- then do nothing with refreshes., valid choices are: 'true', 'false',
- 'wait_for'
+ :arg doc_type: The type of the document
+ :arg pipeline: The pipeline id to preprocess incoming documents
+ with
+ :arg refresh: If `true` then refresh the affected shards to make
+ this operation visible to search, if `wait_for` then wait for a refresh
+ to make this operation visible to search, if `false` (the default) then
+ do nothing with refreshes. Valid choices: true, false, wait_for
: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, valid choices are: 'internal',
- 'external', 'external_gte', 'force'
- :arg wait_for_active_shards: Sets the number of shard copies that must
- be active before proceeding with the index operation. Defaults to 1,
- meaning the primary shard only. Set to `all` for all shard copies,
- otherwise set to any non-negative value less than or equal to the
- total number of copies for the shard (number of replicas + 1)
+ :arg version_type: Specific version type Valid choices:
+ internal, external, external_gte
+ :arg wait_for_active_shards: Sets the number of shard copies
+ that must be active before proceeding with the index operation. Defaults
+ to 1, meaning the primary shard only. Set to `all` for all shard copies,
+ otherwise set to any non-negative value less than or equal to the total
+ number of copies for the shard (number of replicas + 1)
"""
for param in (index, id, body):
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")
+
return self.transport.perform_request(
"PUT", _make_path(index, doc_type, id, "_create"), params=params, body=body
)
@query_params(
- "if_seq_no",
"if_primary_term",
+ "if_seq_no",
"op_type",
- "parent",
"pipeline",
"refresh",
"routing",
"timeout",
- "timestamp",
- "ttl",
"version",
"version_type",
"wait_for_active_shards",
)
- def index(self, index, body, doc_type="_doc", id=None, params=None):
+ def index(self, index, body, doc_type=None, id=None, params=None):
"""
- Adds or updates a typed JSON document in a specific index, making it searchable.
- ``_
+ Creates or updates a document in an index.
+ ``_
:arg index: The name of the index
:arg body: The document
+ :arg doc_type: The type of the document
:arg id: Document ID
- :arg if_primary_term: only perform the index operation if the last
- operation that has changed the document has the specified primary
+ :arg if_primary_term: only perform the index operation if the
+ last operation that has changed the document has the specified primary
term
- :arg if_seq_no: only perform the index operation if the last operation
- that has changed the document has the specified sequence number
- :arg doc_type: Document type, defaults to `_doc`. Not used on ES 7 clusters.
- :arg op_type: Explicit operation type, default 'index', valid choices
- are: 'index', 'create'
- :arg parent: ID of the parent document
- :arg pipeline: The pipeline id to preprocess incoming documents with
- :arg refresh: If `true` then refresh the affected shards to make this
- operation visible to search, if `wait_for` then wait for a refresh
- to make this operation visible to search, if `false` (the default)
- then do nothing with refreshes., valid choices are: 'true', 'false',
- 'wait_for'
+ :arg if_seq_no: only perform the index operation if the last
+ operation that has changed the document has the specified sequence
+ number
+ :arg op_type: Explicit operation type. Defaults to `index` for
+ requests with an explicit document ID, and to `create`for requests
+ without an explicit document ID Valid choices: index, create
+ :arg pipeline: The pipeline id to preprocess incoming documents
+ with
+ :arg refresh: If `true` then refresh the affected shards to make
+ this operation visible to search, if `wait_for` then wait for a refresh
+ to make this operation visible to search, if `false` (the default) then
+ do nothing with refreshes. Valid choices: true, false, wait_for
: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, valid choices are: 'internal',
- 'external', 'external_gte', 'force'
- :arg wait_for_active_shards: Sets the number of shard copies that must
- be active before proceeding with the index operation. Defaults to 1,
- meaning the primary shard only. Set to `all` for all shard copies,
- otherwise set to any non-negative value less than or equal to the
- total number of copies for the shard (number of replicas + 1)
+ :arg version_type: Specific version type Valid choices:
+ internal, external, external_gte
+ :arg wait_for_active_shards: Sets the number of shard copies
+ that must be active before proceeding with the index operation. Defaults
+ to 1, meaning the primary shard only. Set to `all` for all shard copies,
+ otherwise set to any non-negative value less than or equal to the total
+ number of copies for the shard (number of replicas + 1)
"""
for param in (index, body):
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")
+
+ if doc_type is None:
+ doc_type = "_doc"
+
return self.transport.perform_request(
- "POST", _make_path(index, doc_type, id), params=params, body=body
+ "POST" if id in SKIP_IN_PATH else "PUT",
+ _make_path(index, doc_type, id),
+ params=params,
+ body=body,
+ )
+
+ @query_params(
+ "_source",
+ "_source_excludes",
+ "_source_includes",
+ "doc_type",
+ "pipeline",
+ "refresh",
+ "routing",
+ "timeout",
+ "wait_for_active_shards",
+ )
+ def bulk(self, body, index=None, doc_type=None, params=None):
+ """
+ Allows to perform multiple index/update/delete operations in a single request.
+ ``_
+
+ :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 _source: True or false to return the _source field or not,
+ or default list of fields to return, can be overridden on each sub-
+ request
+ :arg _source_excludes: Default list of fields to exclude from
+ the returned _source field, can be overridden on each sub-request
+ :arg _source_includes: Default list of fields to extract and
+ return from the _source field, can be overridden on each sub-request
+ :arg doc_type: Default document type for items which don't
+ provide one
+ :arg pipeline: The pipeline id to preprocess incoming documents
+ with
+ :arg refresh: If `true` then refresh the effected shards to make
+ this operation visible to search, if `wait_for` then wait for a refresh
+ to make this operation visible to search, if `false` (the default) then
+ do nothing with refreshes. Valid choices: true, false, wait_for
+ :arg routing: Specific routing value
+ :arg timeout: Explicit operation timeout
+ :arg wait_for_active_shards: Sets the number of shard copies
+ that must be active before proceeding with the bulk operation. Defaults
+ to 1, meaning the primary shard only. Set to `all` for all shard copies,
+ otherwise set to any non-negative value less than or equal to the total
+ number of copies for the shard (number of replicas + 1)
+ """
+ if body in SKIP_IN_PATH:
+ raise ValueError("Empty value passed for a required argument 'body'.")
+
+ body = self._bulk_body(body)
+ return self.transport.perform_request(
+ "POST", _make_path(index, doc_type, "_bulk"), params=params, body=body
+ )
+
+ @query_params()
+ def clear_scroll(self, body=None, scroll_id=None, params=None):
+ """
+ Explicitly clears the search context for a scroll.
+ ``_
+
+ :arg body: A comma-separated list of scroll IDs to clear if none
+ was specified via the scroll_id parameter
+ :arg scroll_id: A comma-separated list of scroll IDs to clear
+ """
+ if scroll_id in SKIP_IN_PATH and body in SKIP_IN_PATH:
+ raise ValueError("You need to supply scroll_id or body.")
+ elif scroll_id and not body:
+ body = {"scroll_id": [scroll_id]}
+ elif scroll_id:
+ params["scroll_id"] = scroll_id
+
+ return self.transport.perform_request(
+ "DELETE", "/_search/scroll", params=params, body=body
+ )
+
+ @query_params(
+ "allow_no_indices",
+ "analyze_wildcard",
+ "analyzer",
+ "default_operator",
+ "df",
+ "expand_wildcards",
+ "ignore_throttled",
+ "ignore_unavailable",
+ "lenient",
+ "min_score",
+ "preference",
+ "q",
+ "routing",
+ "terminate_after",
+ )
+ def count(self, body=None, index=None, doc_type=None, params=None):
+ """
+ Returns number of documents matching a query.
+ ``_
+
+ :arg body: A query to restrict the results specified with the
+ Query DSL (optional)
+ :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 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) Valid choices: AND, OR Default: 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. Valid choices: open,
+ closed, none, all Default: open
+ :arg ignore_throttled: Whether specified concrete, expanded or
+ aliased indices should be ignored when throttled
+ :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 providing text to a numeric field) should be ignored
+ :arg min_score: Include only documents with a specific `_score`
+ value in the result
+ :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: A comma-separated list of specific routing values
+ :arg terminate_after: The maximum count for each shard, upon
+ reaching which the query execution will terminate early
+ """
+ return self.transport.perform_request(
+ "POST", _make_path(index, doc_type, "_count"), params=params, body=body
+ )
+
+ @query_params(
+ "if_primary_term",
+ "if_seq_no",
+ "refresh",
+ "routing",
+ "timeout",
+ "version",
+ "version_type",
+ "wait_for_active_shards",
+ )
+ def delete(self, index, id, doc_type=None, params=None):
+ """
+ Removes a document from the index.
+ ``_
+
+ :arg index: The name of the index
+ :arg id: The document ID
+ :arg doc_type: The type of the document
+ :arg if_primary_term: only perform the delete operation if the
+ last operation that has changed the document has the specified primary
+ term
+ :arg if_seq_no: only perform the delete operation if the last
+ operation that has changed the document has the specified sequence
+ number
+ :arg refresh: If `true` then refresh the effected shards to make
+ this operation visible to search, if `wait_for` then wait for a refresh
+ to make this operation visible to search, if `false` (the default) then
+ do nothing with refreshes. Valid choices: true, false, wait_for
+ :arg routing: Specific routing value
+ :arg timeout: Explicit operation timeout
+ :arg version: Explicit version number for concurrency control
+ :arg version_type: Specific version type Valid choices:
+ internal, external, external_gte, force
+ :arg wait_for_active_shards: Sets the number of shard copies
+ that must be active before proceeding with the delete operation.
+ Defaults to 1, meaning the primary shard only. Set to `all` for all
+ shard copies, otherwise set to any non-negative value less than or equal
+ to the total number of copies for the shard (number of replicas + 1)
+ """
+ for param in (index, id):
+ if param in SKIP_IN_PATH:
+ raise ValueError("Empty value passed for a required argument.")
+
+ if doc_type is None:
+ doc_type = "_doc"
+
+ return self.transport.perform_request(
+ "DELETE", _make_path(index, doc_type, id), params=params
+ )
+
+ @query_params(
+ "_source",
+ "_source_excludes",
+ "_source_includes",
+ "allow_no_indices",
+ "analyze_wildcard",
+ "conflicts",
+ "default_operator",
+ "df",
+ "expand_wildcards",
+ "from_",
+ "ignore_unavailable",
+ "lenient",
+ "max_docs",
+ "preference",
+ "q",
+ "refresh",
+ "request_cache",
+ "requests_per_second",
+ "routing",
+ "scroll",
+ "scroll_size",
+ "search_timeout",
+ "search_type",
+ "size",
+ "slices",
+ "sort",
+ "stats",
+ "terminate_after",
+ "timeout",
+ "version",
+ "wait_for_active_shards",
+ "wait_for_completion",
+ )
+ def delete_by_query(self, index, body, doc_type=None, params=None):
+ """
+ Deletes documents matching the provided query.
+ ``_
+
+ :arg index: A comma-separated list of index names to search; use
+ `_all` or empty string to perform the operation on all indices
+ :arg body: The search definition using the Query DSL
+ :arg doc_type: A comma-separated list of document types to
+ search; leave empty to perform the operation on all types
+ :arg _source: True or false to return the _source field or not,
+ or a list of fields to return
+ :arg _source_excludes: A list of fields to exclude from the
+ returned _source field
+ :arg _source_includes: 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 conflicts: What to do when the delete by query hits version
+ conflicts? Valid choices: abort, proceed Default: abort
+ :arg default_operator: The default operator for query string
+ query (AND or OR) Valid choices: AND, OR Default: 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. Valid choices: open,
+ closed, none, all Default: open
+ :arg from_: Starting offset (default: 0)
+ :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 providing text to a numeric field) should be ignored
+ :arg max_docs: Maximum number of documents to process (default:
+ all documents)
+ :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 refresh: Should the effected indexes be refreshed?
+ :arg request_cache: Specify if request cache should be used for
+ this request or not, defaults to index level setting
+ :arg requests_per_second: The throttle for this request in sub-
+ requests per second. -1 means no throttle.
+ :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 scroll_size: Size on the scroll request powering the delete
+ by query
+ :arg search_timeout: Explicit timeout for each search request.
+ Defaults to no timeout.
+ :arg search_type: Search operation type Valid choices:
+ query_then_fetch, dfs_query_then_fetch
+ :arg size: Deprecated, please use `max_docs` instead
+ :arg slices: The number of slices this task should be divided
+ into. Defaults to 1 meaning the task isn't sliced into subtasks.
+ Default: 1
+ :arg sort: A comma-separated list of : pairs
+ :arg stats: Specific 'tag' of the request for logging and
+ statistical purposes
+ :arg terminate_after: The maximum number of documents to collect
+ for each shard, upon reaching which the query execution will terminate
+ early.
+ :arg timeout: Time each individual bulk request should wait for
+ shards that are unavailable. Default: 1m
+ :arg version: Specify whether to return document version as part
+ of a hit
+ :arg wait_for_active_shards: Sets the number of shard copies
+ that must be active before proceeding with the delete by query
+ operation. Defaults to 1, meaning the primary shard only. Set to `all`
+ for all shard copies, otherwise set to any non-negative value less than
+ or equal to the total number of copies for the shard (number of replicas
+ + 1)
+ :arg wait_for_completion: Should the request should block until
+ the delete by query is complete. Default: True
+ """
+ # from is a reserved word so it cannot be used, use from_ instead
+ if "from_" in params:
+ params["from"] = params.pop("from_")
+
+ for param in (index, body):
+ if param in SKIP_IN_PATH:
+ raise ValueError("Empty value passed for a required argument.")
+
+ return self.transport.perform_request(
+ "POST",
+ _make_path(index, doc_type, "_delete_by_query"),
+ params=params,
+ body=body,
+ )
+
+ @query_params("requests_per_second")
+ def delete_by_query_rethrottle(self, task_id, params=None):
+ """
+ Changes the number of requests per second for a particular Delete By Query
+ operation.
+ ``_
+
+ :arg task_id: The task id to rethrottle
+ :arg requests_per_second: The throttle to set on this request in
+ floating sub-requests per second. -1 means set no throttle.
+ """
+ if task_id in SKIP_IN_PATH:
+ raise ValueError("Empty value passed for a required argument 'task_id'.")
+
+ return self.transport.perform_request(
+ "POST",
+ _make_path("_delete_by_query", task_id, "_rethrottle"),
+ params=params,
+ )
+
+ @query_params("master_timeout", "timeout")
+ def delete_script(self, id, params=None):
+ """
+ Deletes a script.
+ ``_
+
+ :arg id: Script ID
+ :arg master_timeout: Specify timeout for connection to master
+ :arg timeout: Explicit operation timeout
+ """
+ if id in SKIP_IN_PATH:
+ raise ValueError("Empty value passed for a required argument 'id'.")
+
+ return self.transport.perform_request(
+ "DELETE", _make_path("_scripts", id), params=params
)
@query_params(
"_source",
"_source_excludes",
"_source_includes",
- "parent",
"preference",
"realtime",
"refresh",
@@ -412,36 +763,41 @@ class Elasticsearch(object):
"version",
"version_type",
)
- def exists(self, index, id, doc_type="_doc", params=None):
+ def exists(self, index, id, doc_type=None, params=None):
"""
- Returns a boolean indicating whether or not given document exists in Elasticsearch.
- ``_
+ Returns information about whether a document exists in an index.
+ ``_
:arg index: The name of the index
:arg id: The document ID
- :arg _source: True or false to return the _source field or not, or a
- list of fields to return
- :arg _source_excludes: A list of fields to exclude from the returned
- _source field
- :arg _source_includes: A list of fields to extract and return from the
- _source field
- :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 doc_type: The type of the document (use `_all` 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_excludes: A list of fields to exclude from the
+ returned _source field
+ :arg _source_includes: A list of fields to extract and return
+ from the _source field
+ :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 refresh: Refresh the shard containing the document before
performing the operation
:arg routing: Specific routing value
- :arg stored_fields: A comma-separated list of stored fields to return in
- the response
+ :arg stored_fields: A comma-separated list of stored fields to
+ return in the response
:arg version: Explicit version number for concurrency control
- :arg version_type: Specific version type, valid choices are: 'internal',
- 'external', 'external_gte', 'force'
+ :arg version_type: Specific version type Valid choices:
+ internal, external, external_gte, force
"""
for param in (index, id):
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")
+
+ if doc_type is None:
+ doc_type = "_doc"
+
return self.transport.perform_request(
"HEAD", _make_path(index, doc_type, id), params=params
)
@@ -450,7 +806,6 @@ class Elasticsearch(object):
"_source",
"_source_excludes",
"_source_includes",
- "parent",
"preference",
"realtime",
"refresh",
@@ -460,31 +815,34 @@ class Elasticsearch(object):
)
def exists_source(self, index, id, doc_type=None, params=None):
"""
- ``_
+ Returns information about whether a document source exists in an index.
+ ``_
:arg index: The name of the index
:arg id: The document ID
- :arg _source: True or false to return the _source field or not, or a
- list of fields to return
- :arg _source_excludes: A list of fields to exclude from the returned
- _source field
- :arg _source_includes: A list of fields to extract and return from the
- _source field
- :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 doc_type: The type of the document; deprecated and optional
+ starting with 7.0
+ :arg _source: True or false to return the _source field or not,
+ or a list of fields to return
+ :arg _source_excludes: A list of fields to exclude from the
+ returned _source field
+ :arg _source_includes: A list of fields to extract and return
+ from the _source field
+ :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 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: Specific version type, valid choices are: 'internal',
- 'external', 'external_gte', 'force'
+ :arg version_type: Specific version type Valid choices:
+ internal, external, external_gte, force
"""
for param in (index, id):
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")
+
return self.transport.perform_request(
"HEAD", _make_path(index, doc_type, id, "_source"), params=params
)
@@ -493,7 +851,90 @@ class Elasticsearch(object):
"_source",
"_source_excludes",
"_source_includes",
- "parent",
+ "analyze_wildcard",
+ "analyzer",
+ "default_operator",
+ "df",
+ "lenient",
+ "preference",
+ "q",
+ "routing",
+ "stored_fields",
+ )
+ def explain(self, index, id, body=None, doc_type=None, params=None):
+ """
+ Returns information about why a specific matches (or doesn't match) a query.
+ ``_
+
+ :arg index: The name of the index
+ :arg id: The document ID
+ :arg body: The query definition using the Query DSL
+ :arg doc_type: The type of the document
+ :arg _source: True or false to return the _source field or not,
+ or a list of fields to return
+ :arg _source_excludes: A list of fields to exclude from the
+ returned _source field
+ :arg _source_includes: A list of fields to extract and return
+ from the _source field
+ :arg analyze_wildcard: Specify whether wildcards and prefix
+ queries in 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) Valid choices: AND, OR Default: OR
+ :arg df: The default field for query string query (default:
+ _all)
+ :arg lenient: Specify whether format-based query failures (such
+ as providing text to a numeric field) should be ignored
+ :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 stored_fields: A comma-separated list of stored fields to
+ return in the response
+ """
+ for param in (index, id):
+ if param in SKIP_IN_PATH:
+ raise ValueError("Empty value passed for a required argument.")
+
+ return self.transport.perform_request(
+ "GET", _make_path(index, doc_type, id, "_explain"), params=params, body=body
+ )
+
+ @query_params(
+ "allow_no_indices",
+ "expand_wildcards",
+ "fields",
+ "ignore_unavailable",
+ "include_unmapped",
+ )
+ def field_caps(self, index=None, params=None):
+ """
+ Returns the information about the capabilities of fields among multiple
+ indices.
+ ``_
+
+ :arg index: A comma-separated list of index names; use `_all` or
+ empty string to perform the operation on all indices
+ :arg allow_no_indices: Whether to ignore if a wildcard indices
+ expression resolves into no concrete indices. (This includes `_all`
+ string or when no indices have been specified)
+ :arg expand_wildcards: Whether to expand wildcard expression to
+ concrete indices that are open, closed or both. Valid choices: open,
+ closed, none, all Default: open
+ :arg fields: A comma-separated list of field names
+ :arg ignore_unavailable: Whether specified concrete indices
+ should be ignored when unavailable (missing or closed)
+ :arg include_unmapped: Indicates whether unmapped fields should
+ be included in the response.
+ """
+ return self.transport.perform_request(
+ "GET", _make_path(index, "_field_caps"), params=params
+ )
+
+ @query_params(
+ "_source",
+ "_source_excludes",
+ "_source_includes",
"preference",
"realtime",
"refresh",
@@ -502,45 +943,65 @@ class Elasticsearch(object):
"version",
"version_type",
)
- def get(self, index, id, doc_type="_doc", params=None):
+ def get(self, index, id, doc_type=None, params=None):
"""
- Get a typed JSON document from the index based on its id.
- ``_
+ Returns a document.
+ ``_
:arg index: The name of the index
:arg id: The document ID
- :arg _source: True or false to return the _source field or not, or a
- list of fields to return
- :arg _source_excludes: A list of fields to exclude from the returned
- _source field
- :arg _source_includes: A list of fields to extract and return from the
- _source field
- :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 doc_type: The type of the document (use `_all` 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_excludes: A list of fields to exclude from the
+ returned _source field
+ :arg _source_includes: A list of fields to extract and return
+ from the _source field
+ :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 refresh: Refresh the shard containing the document before
performing the operation
:arg routing: Specific routing value
- :arg stored_fields: A comma-separated list of stored fields to return in
- the response
+ :arg stored_fields: A comma-separated list of stored fields to
+ return in the response
:arg version: Explicit version number for concurrency control
- :arg version_type: Specific version type, valid choices are: 'internal',
- 'external', 'external_gte', 'force'
+ :arg version_type: Specific version type Valid choices:
+ internal, external, external_gte, force
"""
for param in (index, id):
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")
+
+ if doc_type is None:
+ doc_type = "_doc"
+
return self.transport.perform_request(
"GET", _make_path(index, doc_type, id), params=params
)
+ @query_params("master_timeout")
+ def get_script(self, id, params=None):
+ """
+ Returns a script.
+ ``_
+
+ :arg id: Script ID
+ :arg master_timeout: Specify timeout for connection to master
+ """
+ if id in SKIP_IN_PATH:
+ raise ValueError("Empty value passed for a required argument 'id'.")
+
+ return self.transport.perform_request(
+ "GET", _make_path("_scripts", id), params=params
+ )
+
@query_params(
"_source",
"_source_excludes",
"_source_includes",
- "parent",
"preference",
"realtime",
"refresh",
@@ -548,34 +1009,36 @@ class Elasticsearch(object):
"version",
"version_type",
)
- def get_source(self, index, id, doc_type="_doc", params=None):
+ def get_source(self, index, id, doc_type=None, params=None):
"""
- Get the source of a document by it's index, type and id.
- ``_
+ Returns the source of a document.
+ ``_
:arg index: The name of the index
:arg id: The document ID
- :arg _source: True or false to return the _source field or not, or a
- list of fields to return
- :arg _source_excludes: A list of fields to exclude from the returned
- _source field
- :arg _source_includes: A list of fields to extract and return from the
- _source field
- :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 doc_type: The type of the document; deprecated and optional
+ starting with 7.0
+ :arg _source: True or false to return the _source field or not,
+ or a list of fields to return
+ :arg _source_excludes: A list of fields to exclude from the
+ returned _source field
+ :arg _source_includes: A list of fields to extract and return
+ from the _source field
+ :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 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: Specific version type, valid choices are: 'internal',
- 'external', 'external_gte', 'force'
+ :arg version_type: Specific version type Valid choices:
+ internal, external, external_gte, force
"""
for param in (index, id):
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")
+
return self.transport.perform_request(
"GET", _make_path(index, doc_type, id, "_source"), params=params
)
@@ -590,101 +1053,349 @@ class Elasticsearch(object):
"routing",
"stored_fields",
)
- def mget(self, body, doc_type=None, index=None, params=None):
+ def mget(self, body, index=None, doc_type=None, params=None):
"""
- Get multiple documents based on an index, type (optional) and ids.
- ``_
+ Allows to get multiple documents in one request.
+ ``_
- :arg body: Document identifiers; can be either `docs` (containing full
- document information) or `ids` (when index and type is provided in
- the URL.
+ :arg body: Document identifiers; can be either `docs`
+ (containing full document information) or `ids` (when index and type is
+ provided in the URL.
:arg index: The name of the index
- :arg _source: True or false to return the _source field or not, or a
- list of fields to return
- :arg _source_excludes: A list of fields to exclude from the returned
- _source field
- :arg _source_includes: A list of fields to extract and return from the
- _source field
- :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 doc_type: The type of the document
+ :arg _source: True or false to return the _source field or not,
+ or a list of fields to return
+ :arg _source_excludes: A list of fields to exclude from the
+ returned _source field
+ :arg _source_includes: A list of fields to extract and return
+ from the _source field
+ :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 refresh: Refresh the shard containing the document before
performing the operation
:arg routing: Specific routing value
- :arg stored_fields: A comma-separated list of stored fields to return in
- the response
+ :arg stored_fields: A comma-separated list of stored fields to
+ return in the response
"""
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")
+
return self.transport.perform_request(
"GET", _make_path(index, doc_type, "_mget"), params=params, body=body
)
@query_params(
- "_source",
- "_source_excludes",
- "_source_includes",
+ "ccs_minimize_roundtrips",
+ "max_concurrent_searches",
+ "max_concurrent_shard_requests",
+ "pre_filter_shard_size",
+ "rest_total_hits_as_int",
+ "search_type",
+ "typed_keys",
+ )
+ def msearch(self, body, index=None, doc_type=None, params=None):
+ """
+ Allows to execute several search operations in one request.
+ ``_
+
+ :arg body: The request definitions (metadata-search request
+ definition 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 ccs_minimize_roundtrips: Indicates whether network round-
+ trips should be minimized as part of cross-cluster search requests
+ execution Default: true
+ :arg max_concurrent_searches: Controls the maximum number of
+ concurrent searches the multi search api will execute
+ :arg max_concurrent_shard_requests: The number of concurrent
+ shard requests each sub search executes concurrently per node. This
+ value should be used to limit the impact of the search on the cluster in
+ order to limit the number of concurrent shard requests Default: 5
+ :arg pre_filter_shard_size: A threshold that enforces a pre-
+ filter roundtrip to prefilter search shards based on query rewriting if
+ the number of shards the search request expands to exceeds the
+ threshold. This filter roundtrip can limit the number of shards
+ significantly if for instance a shard can not match any documents based
+ on it's rewrite method ie. if date filters are mandatory to match but
+ the shard bounds and the query are disjoint. Default: 128
+ :arg rest_total_hits_as_int: Indicates whether hits.total should
+ be rendered as an integer or an object in the rest search response
+ :arg search_type: Search operation type Valid choices:
+ query_then_fetch, query_and_fetch, dfs_query_then_fetch,
+ dfs_query_and_fetch
+ :arg typed_keys: Specify whether aggregation and suggester names
+ should be prefixed by their respective types in the response
+ """
+ if body in SKIP_IN_PATH:
+ raise ValueError("Empty value passed for a required argument 'body'.")
+
+ body = self._bulk_body(body)
+ return self.transport.perform_request(
+ "GET", _make_path(index, doc_type, "_msearch"), params=params, body=body
+ )
+
+ @query_params(
+ "max_concurrent_searches", "rest_total_hits_as_int", "search_type", "typed_keys"
+ )
+ def msearch_template(self, body, index=None, doc_type=None, params=None):
+ """
+ Allows to execute several search template operations in one request.
+ ``_
+
+ :arg body: The request definitions (metadata-search request
+ definition 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 max_concurrent_searches: Controls the maximum number of
+ concurrent searches the multi search api will execute
+ :arg rest_total_hits_as_int: Indicates whether hits.total should
+ be rendered as an integer or an object in the rest search response
+ :arg search_type: Search operation type Valid choices:
+ query_then_fetch, query_and_fetch, dfs_query_then_fetch,
+ dfs_query_and_fetch
+ :arg typed_keys: Specify whether aggregation and suggester names
+ should be prefixed by their respective types in the response
+ """
+ if body in SKIP_IN_PATH:
+ raise ValueError("Empty value passed for a required argument 'body'.")
+
+ body = self._bulk_body(body)
+ return self.transport.perform_request(
+ "GET",
+ _make_path(index, doc_type, "_msearch", "template"),
+ params=params,
+ body=body,
+ )
+
+ @query_params(
+ "field_statistics",
"fields",
- "if_seq_no",
- "if_primary_term",
- "lang",
- "parent",
- "refresh",
- "retry_on_conflict",
+ "ids",
+ "offsets",
+ "payloads",
+ "positions",
+ "preference",
+ "realtime",
"routing",
- "timeout",
- "timestamp",
- "ttl",
+ "term_statistics",
"version",
"version_type",
- "wait_for_active_shards",
)
- def update(self, index, id, doc_type="_doc", body=None, params=None):
+ def mtermvectors(self, body=None, index=None, doc_type=None, params=None):
"""
- Update a document based on a script or partial data provided.
- ``_
+ Returns multiple termvectors in one request.
+ ``_
- :arg index: The name of the index
- :arg id: Document ID
- :arg body: The request definition using either `script` or partial `doc`
- :arg _source: True or false to return the _source field or not, or a
- list of fields to return
- :arg _source_excludes: A list of fields to exclude from the returned
- _source field
- :arg _source_includes: 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 if_seq_no:
- :arg if_primary_term:
- :arg lang: The script language (default: painless)
- :arg parent: ID of the parent document. Is is only used for routing and
- when for the upsert request
- :arg refresh: If `true` then refresh the effected shards to make this
- operation visible to search, if `wait_for` then wait for a refresh
- to make this operation visible to search, if `false` (the default)
- then do nothing with refreshes., valid choices are: 'true', 'false',
- 'wait_for'
- :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 timeout: Explicit operation timeout
- :arg timestamp: Explicit timestamp for the document
- :arg ttl: Expiration time for the document
+ :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 index: The index in which the document resides.
+ :arg doc_type: The type of the document.
+ :arg field_statistics: Specifies if document count, sum of
+ document frequencies and sum of total term frequencies should be
+ returned. Applies to all returned documents unless otherwise specified
+ in body "params" or "docs". Default: True
+ :arg fields: A comma-separated list of fields to return. Applies
+ to all returned documents unless otherwise specified in body "params" or
+ "docs".
+ :arg ids: A comma-separated list of documents ids. You must
+ define ids as parameter or set "ids" or "docs" in the request body
+ :arg offsets: Specifies if term offsets should be returned.
+ Applies to all returned documents unless otherwise specified in body
+ "params" or "docs". Default: True
+ :arg payloads: Specifies if term payloads should be returned.
+ Applies to all returned documents unless otherwise specified in body
+ "params" or "docs". Default: True
+ :arg positions: Specifies if term positions should be returned.
+ Applies to all returned documents unless otherwise specified in body
+ "params" or "docs". Default: True
+ :arg preference: Specify the node or shard the operation should
+ be performed on (default: random) .Applies to all returned documents
+ unless otherwise specified in body "params" or "docs".
+ :arg realtime: Specifies if requests are real-time as opposed to
+ near-real-time (default: true).
+ :arg routing: Specific routing value. Applies to all returned
+ documents unless otherwise specified in body "params" or "docs".
+ :arg term_statistics: Specifies if total term frequency and
+ document frequency should be returned. Applies to all returned documents
+ unless otherwise specified in body "params" or "docs".
:arg version: Explicit version number for concurrency control
- :arg version_type: Specific version type, valid choices are: 'internal',
- 'force'
- :arg wait_for_active_shards: Sets the number of shard copies that must
- be active before proceeding with the update operation. Defaults to
- 1, meaning the primary shard only. Set to `all` for all shard
- copies, otherwise set to any non-negative value less than or equal
- to the total number of copies for the shard (number of replicas + 1)
+ :arg version_type: Specific version type Valid choices:
+ internal, external, external_gte, force
"""
- for param in (index, id):
+ return self.transport.perform_request(
+ "GET",
+ _make_path(index, doc_type, "_mtermvectors"),
+ params=params,
+ body=body,
+ )
+
+ @query_params("context", "master_timeout", "timeout")
+ def put_script(self, id, body, context=None, params=None):
+ """
+ Creates or updates a script.
+ ``_
+
+ :arg id: Script ID
+ :arg body: The document
+ :arg context: Script context
+ :arg context: Context name to compile script against
+ :arg master_timeout: Specify timeout for connection to master
+ :arg timeout: Explicit operation timeout
+ """
+ for param in (id, body):
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")
+
return self.transport.perform_request(
- "POST", _make_path(index, doc_type, id, "_update"), params=params, body=body
+ "PUT", _make_path("_scripts", id, context), params=params, body=body
+ )
+
+ @query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable")
+ def rank_eval(self, body, index=None, params=None):
+ """
+ Allows to evaluate the quality of ranked search results over a set of typical
+ search queries
+ ``_
+
+ :arg body: The ranking evaluation search definition, including
+ search requests, document ratings and ranking metric definition.
+ :arg index: A comma-separated list of index names to search; 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. Valid choices: open,
+ closed, none, all Default: open
+ :arg ignore_unavailable: Whether specified concrete indices
+ should be ignored when unavailable (missing or closed)
+ """
+ if body in SKIP_IN_PATH:
+ raise ValueError("Empty value passed for a required argument 'body'.")
+
+ return self.transport.perform_request(
+ "GET", _make_path(index, "_rank_eval"), params=params, body=body
+ )
+
+ @query_params(
+ "max_docs",
+ "refresh",
+ "requests_per_second",
+ "scroll",
+ "slices",
+ "timeout",
+ "wait_for_active_shards",
+ "wait_for_completion",
+ )
+ def reindex(self, body, params=None):
+ """
+ Allows to copy documents from one index to another, optionally filtering the
+ source documents by a query, changing the destination index settings, or
+ fetching the documents from a remote cluster.
+ ``_
+
+ :arg body: The search definition using the Query DSL and the
+ prototype for the index request.
+ :arg max_docs: Maximum number of documents to process (default:
+ all documents)
+ :arg refresh: Should the effected indexes be refreshed?
+ :arg requests_per_second: The throttle to set on this request in
+ sub-requests per second. -1 means no throttle.
+ :arg scroll: Control how long to keep the search context alive
+ Default: 5m
+ :arg slices: The number of slices this task should be divided
+ into. Defaults to 1 meaning the task isn't sliced into subtasks.
+ Default: 1
+ :arg timeout: Time each individual bulk request should wait for
+ shards that are unavailable. Default: 1m
+ :arg wait_for_active_shards: Sets the number of shard copies
+ that must be active before proceeding with the reindex operation.
+ Defaults to 1, meaning the primary shard only. Set to `all` for all
+ shard copies, otherwise set to any non-negative value less than or equal
+ to the total number of copies for the shard (number of replicas + 1)
+ :arg wait_for_completion: Should the request should block until
+ the reindex is complete. Default: True
+ """
+ if body in SKIP_IN_PATH:
+ raise ValueError("Empty value passed for a required argument 'body'.")
+
+ return self.transport.perform_request(
+ "POST", "/_reindex", params=params, body=body
+ )
+
+ @query_params("requests_per_second")
+ def reindex_rethrottle(self, task_id, params=None):
+ """
+ Changes the number of requests per second for a particular Reindex operation.
+ ``_
+
+ :arg task_id: The task id to rethrottle
+ :arg requests_per_second: The throttle to set on this request in
+ floating sub-requests per second. -1 means set no throttle.
+ """
+ if task_id in SKIP_IN_PATH:
+ raise ValueError("Empty value passed for a required argument 'task_id'.")
+
+ return self.transport.perform_request(
+ "POST", _make_path("_reindex", task_id, "_rethrottle"), params=params
+ )
+
+ @query_params()
+ def render_search_template(self, body=None, id=None, params=None):
+ """
+ Allows to use the Mustache language to pre-render a search definition.
+ ``_
+
+ :arg body: The search definition template and its params
+ :arg id: The id of the stored search template
+ """
+ return self.transport.perform_request(
+ "GET", _make_path("_render", "template", id), params=params, body=body
+ )
+
+ @query_params()
+ def scripts_painless_execute(self, body=None, params=None):
+ """
+ Allows an arbitrary script to be executed and a result to be returned
+ ``_
+
+ :arg body: The script to execute
+ """
+ return self.transport.perform_request(
+ "GET", "/_scripts/painless/_execute", params=params, body=body
+ )
+
+ @query_params("rest_total_hits_as_int", "scroll", "scroll_id")
+ def scroll(self, body=None, scroll_id=None, params=None):
+ """
+ Allows to retrieve a large numbers of results from a single search request.
+ ``_
+
+ :arg body: The scroll ID if not passed by URL or query
+ parameter.
+ :arg scroll_id: The scroll ID
+ :arg rest_total_hits_as_int: Indicates whether hits.total should
+ be rendered as an integer or an object in the rest search response
+ :arg scroll: Specify how long a consistent view of the index
+ should be maintained for scrolled search
+ :arg scroll_id: The scroll ID for scrolled search
+ """
+ if scroll_id in SKIP_IN_PATH and body in SKIP_IN_PATH:
+ raise ValueError("You need to supply scroll_id or body.")
+ elif scroll_id and not body:
+ body = {"scroll_id": scroll_id}
+ elif scroll_id:
+ params["scroll_id"] = scroll_id
+
+ return self.transport.perform_request(
+ "GET", "/_search/scroll", params=params, body=body
)
@query_params(
@@ -710,8 +1421,8 @@ class Elasticsearch(object):
"pre_filter_shard_size",
"preference",
"q",
- "rest_total_hits_as_int",
"request_cache",
+ "rest_total_hits_as_int",
"routing",
"scroll",
"search_type",
@@ -731,438 +1442,113 @@ class Elasticsearch(object):
"typed_keys",
"version",
)
- def search(self, index=None, body=None, params=None):
+ def search(self, body=None, index=None, doc_type=None, params=None):
"""
- Execute a search query and get back search hits that match the query.
- ``_
+ Returns results matching a query.
+ ``_
- :arg index: A list of index names to search, or a string containing a
- comma-separated list of index names to search; use `_all`
- or empty string to perform the operation on all indices
: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
- :arg _source_excludes: A list of fields to exclude from the returned
- _source field
- :arg _source_includes: A list of fields to extract and return from the
- _source field
+ :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 _source: True or false to return the _source field or not,
+ or a list of fields to return
+ :arg _source_excludes: A list of fields to exclude from the
+ returned _source field
+ :arg _source_includes: 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 allow_partial_search_results: Set to false to return an overall
- failure if the request would produce partial results. Defaults to
- True, which will allow partial results in the case of timeouts or
- partial failures
- :arg analyze_wildcard: Specify whether wildcard and prefix queries
- should be analyzed (default: false)
+ :arg allow_partial_search_results: Indicate if an error should
+ be returned if there is a partial search failure or timeout Default:
+ True
+ :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 batched_reduce_size: The number of shard results that should be
- reduced at once on the coordinating node. This value should be used
- as a protection mechanism to reduce the memory overhead per search
- request if the potential number of shards in the request can be
- large., default 512
- :arg ccs_minimize_roundtrips: Indicates whether network round-trips
- should be minimized as part of cross-cluster search requests
- execution, default 'true'
- :arg default_operator: The default operator for query string query (AND
- 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 docvalue_fields: A comma-separated list of fields to return as the
- docvalue representation of a field for each 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 from\\_: Starting offset (default: 0)
- :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
- providing text to a numeric field) should be ignored
- :arg max_concurrent_shard_requests: The number of concurrent shard
- requests this search executes concurrently. This value should be
- used to limit the impact of the search on the cluster in order to
- limit the number of concurrent shard requests, default 'The default
- grows with the number of nodes in the cluster but is at most 256.'
- :arg pre_filter_shard_size: A threshold that enforces a pre-filter
- roundtrip to prefilter search shards based on query rewriting if
- the number of shards the search request expands to exceeds the
+ :arg batched_reduce_size: The number of shard results that
+ should be reduced at once on the coordinating node. This value should be
+ used as a protection mechanism to reduce the memory overhead per search
+ request if the potential number of shards in the request can be large.
+ Default: 512
+ :arg ccs_minimize_roundtrips: Indicates whether network round-
+ trips should be minimized as part of cross-cluster search requests
+ execution Default: true
+ :arg default_operator: The default operator for query string
+ query (AND or OR) Valid choices: AND, OR Default: OR
+ :arg df: The field to use as default where no field prefix is
+ given in the query string
+ :arg docvalue_fields: A comma-separated list of fields to return
+ as the docvalue representation of a field for each hit
+ :arg expand_wildcards: Whether to expand wildcard expression to
+ concrete indices that are open, closed or both. Valid choices: open,
+ closed, none, all Default: open
+ :arg explain: Specify whether to return detailed information
+ about score computation as part of a hit
+ :arg from_: Starting offset (default: 0)
+ :arg ignore_throttled: Whether specified concrete, expanded or
+ aliased indices should be ignored when throttled
+ :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 providing text to a numeric field) should be ignored
+ :arg max_concurrent_shard_requests: The number of concurrent
+ shard requests per node this search executes concurrently. This value
+ should be used to limit the impact of the search on the cluster in order
+ to limit the number of concurrent shard requests Default: 5
+ :arg pre_filter_shard_size: A threshold that enforces a pre-
+ filter roundtrip to prefilter search shards based on query rewriting if
+ the number of shards the search request expands to exceeds the
threshold. This filter roundtrip can limit the number of shards
- significantly if for instance a shard can not match any documents
- based on it's rewrite method ie. if date filters are mandatory to
- match but the shard bounds and the query are disjoint., default 128
- :arg preference: Specify the node or shard the operation should be
- performed on (default: random)
+ significantly if for instance a shard can not match any documents based
+ on it's rewrite method ie. if date filters are mandatory to match but
+ the shard bounds and the query are disjoint. Default: 128
+ :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 rest_total_hits_as_int: This parameter is used to restore the total hits as a number
- in the response. This param is added version 6.x to handle mixed cluster queries where nodes
- are in multiple versions (7.0 and 6.latest)
- :arg request_cache: Specify if request cache should be used for this
- request or not, defaults to index level setting
+ :arg request_cache: Specify if request cache should be used for
+ this request or not, defaults to index level setting
+ :arg rest_total_hits_as_int: Indicates whether hits.total should
+ be rendered as an integer or an object in the rest search response
: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, valid choices are:
- 'query_then_fetch', 'dfs_query_then_fetch'
+ :arg scroll: Specify how long a consistent view of the index
+ should be maintained for scrolled search
+ :arg search_type: Search operation type Valid choices:
+ query_then_fetch, dfs_query_then_fetch
+ :arg seq_no_primary_term: Specify whether to return sequence
+ number and primary term of the last modification of each hit
:arg size: Number of hits to return (default: 10)
:arg sort: A comma-separated list of : pairs
- :arg stats: Specific 'tag' of the request for logging and statistical
- purposes
- :arg stored_fields: A comma-separated list of stored fields to return as
- part of a hit
+ :arg stats: Specific 'tag' of the request for logging and
+ statistical purposes
+ :arg stored_fields: A comma-separated list of stored fields to
+ return as part of a hit
:arg suggest_field: Specify which field to use for suggestions
- :arg suggest_mode: Specify suggest mode, default 'missing', valid
- choices are: 'missing', 'popular', 'always'
+ :arg suggest_mode: Specify suggest mode Valid choices: missing,
+ popular, always Default: missing
:arg suggest_size: How many suggestions to return in response
- :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
+ :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 track_total_hits: Indicate if the number of documents that match
- the query should be tracked
- :arg typed_keys: Specify whether aggregation and suggester names should
- be prefixed by their respective types in the response
- :arg version: Specify whether to return document version as part of a
- hit
+ :arg track_scores: Whether to calculate and return scores even
+ if they are not used for sorting
+ :arg track_total_hits: Indicate if the number of documents that
+ match the query should be tracked
+ :arg typed_keys: Specify whether aggregation and suggester names
+ should be prefixed by their respective types in the response
+ :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:
params["from"] = params.pop("from_")
- if not index:
- index = "_all"
return self.transport.perform_request(
- "GET", _make_path(index, "_search"), params=params, body=body
- )
-
- @query_params(
- "_source",
- "_source_excludes",
- "_source_includes",
- "allow_no_indices",
- "analyze_wildcard",
- "analyzer",
- "conflicts",
- "default_operator",
- "df",
- "expand_wildcards",
- "from_",
- "ignore_unavailable",
- "lenient",
- "pipeline",
- "preference",
- "q",
- "refresh",
- "request_cache",
- "requests_per_second",
- "routing",
- "scroll",
- "scroll_size",
- "search_timeout",
- "search_type",
- "size",
- "slices",
- "sort",
- "stats",
- "terminate_after",
- "timeout",
- "version",
- "version_type",
- "wait_for_active_shards",
- "wait_for_completion",
- )
- def update_by_query(self, index, body=None, params=None):
- """
- Perform an update on all documents matching a query.
- ``_
-
- :arg index: A list of index names to search, or a string containing a
- comma-separated list of index names to search; use `_all` or the
- empty string to perform the operation on all indices
- :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
- :arg _source_excludes: A list of fields to exclude from the returned
- _source field
- :arg _source_includes: 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 conflicts: What to do when the update by query hits version
- conflicts?, default 'abort', valid choices are: 'abort', 'proceed'
- :arg default_operator: The default operator for query string query (AND
- 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', valid
- choices are: 'open', 'closed', 'none', 'all'
- :arg from\\_: Starting offset (default: 0)
- :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
- providing text to a numeric field) should be ignored
- :arg pipeline: Ingest pipeline to set on index requests made by this
- action. (default: none)
- :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 refresh: Should the effected indexes be refreshed?
- :arg request_cache: Specify if request cache should be used for this
- request or not, defaults to index level setting
- :arg requests_per_second: The throttle to set on this request in sub-
- requests per second. -1 means no throttle., default 0
- :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 scroll_size: Size on the scroll request powering the
- update_by_query
- :arg search_timeout: Explicit timeout for each search request. Defaults
- to no timeout.
- :arg search_type: Search operation type, valid choices are:
- 'query_then_fetch', 'dfs_query_then_fetch'
- :arg size: Number of hits to return (default: 10)
- :arg slices: The number of slices this task should be divided into.
- Defaults to 1 meaning the task isn't sliced into subtasks., default
- 1
- :arg sort: A comma-separated list of : pairs
- :arg stats: Specific 'tag' of the request for logging and statistical
- purposes
- :arg terminate_after: The maximum number of documents to collect for
- each shard, upon reaching which the query execution will terminate
- early.
- :arg timeout: Time each individual bulk request should wait for shards
- that are unavailable., default '1m'
- :arg version: Specify whether to return document version as part of a
- hit
- :arg version_type: Should the document increment the version number
- (internal) on hit or not (reindex)
- :arg wait_for_active_shards: Sets the number of shard copies that must
- be active before proceeding with the update by query operation.
- Defaults to 1, meaning the primary shard only. Set to `all` for all
- shard copies, otherwise set to any non-negative value less than or
- equal to the total number of copies for the shard (number of
- replicas + 1)
- :arg wait_for_completion: Should the request should block until the
- update by query operation is complete., default True
- """
- if index in SKIP_IN_PATH:
- raise ValueError("Empty value passed for a required argument 'index'.")
- return self.transport.perform_request(
- "POST", _make_path(index, "_update_by_query"), params=params, body=body
- )
-
- @query_params("requests_per_second")
- def update_by_query_rethrottle(self, task_id, params=None):
- """
- ``_
-
- :arg task_id: The task id to rethrottle
- :arg requests_per_second: The throttle to set on this request in
- floating sub-requests per second. -1 means set no throttle.
- """
- if task_id in SKIP_IN_PATH:
- raise ValueError("Empty value passed for a required argument 'task_id'.")
- return self.transport.perform_request(
- "POST",
- _make_path("_update_by_query", task_id, "_rethrottle"),
- params=params,
- )
-
- @query_params(
- "refresh",
- "requests_per_second",
- "slices",
- "scroll",
- "timeout",
- "wait_for_active_shards",
- "wait_for_completion",
- )
- def reindex(self, body, params=None):
- """
- Reindex all documents from one index to another.
- ``_
-
- :arg body: The search definition using the Query DSL and the prototype
- for the index request.
- :arg refresh: Should the effected indexes be refreshed?
- :arg requests_per_second: The throttle to set on this request in sub-
- requests per second. -1 means no throttle., default 0
- :arg slices: The number of slices this task should be divided into.
- Defaults to 1 meaning the task isn't sliced into subtasks., default
- 1
- :arg scroll: Control how long to keep the search context alive, default
- '5m'
- :arg timeout: Time each individual bulk request should wait for shards
- that are unavailable., default '1m'
- :arg wait_for_active_shards: Sets the number of shard copies that must
- be active before proceeding with the reindex operation. Defaults to
- 1, meaning the primary shard only. Set to `all` for all shard
- copies, otherwise set to any non-negative value less than or equal
- to the total number of copies for the shard (number of replicas + 1)
- :arg wait_for_completion: Should the request should block until the
- reindex is complete., default True
- """
- if body in SKIP_IN_PATH:
- raise ValueError("Empty value passed for a required argument 'body'.")
- return self.transport.perform_request(
- "POST", "/_reindex", params=params, body=body
- )
-
- @query_params("requests_per_second")
- def reindex_rethrottle(self, task_id=None, params=None):
- """
- Change the value of ``requests_per_second`` of a running ``reindex`` task.
- ``_
-
- :arg task_id: The task id to rethrottle
- :arg requests_per_second: The throttle to set on this request in
- floating sub-requests per second. -1 means set no throttle.
- """
- return self.transport.perform_request(
- "POST", _make_path("_reindex", task_id, "_rethrottle"), params=params
- )
-
- @query_params(
- "_source",
- "_source_excludes",
- "_source_includes",
- "allow_no_indices",
- "analyze_wildcard",
- "analyzer",
- "conflicts",
- "default_operator",
- "df",
- "expand_wildcards",
- "from_",
- "ignore_unavailable",
- "lenient",
- "preference",
- "q",
- "refresh",
- "request_cache",
- "requests_per_second",
- "routing",
- "scroll",
- "scroll_size",
- "search_timeout",
- "search_type",
- "size",
- "slices",
- "sort",
- "stats",
- "terminate_after",
- "timeout",
- "version",
- "wait_for_active_shards",
- "wait_for_completion",
- )
- def delete_by_query(self, index, body, params=None):
- """
- Delete all documents matching a query.
- ``_
-
- :arg index: A list of index names to search, or a string containing a
- comma-separated list of index names to search; use `_all` or the
- empty string to perform the operation on all indices
- :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
- :arg _source_excludes: A list of fields to exclude from the returned
- _source field
- :arg _source_includes: 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 conflicts: What to do when the delete-by-query hits version
- conflicts?, default 'abort', valid choices are: 'abort', 'proceed'
- :arg default_operator: The default operator for query string query (AND
- 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', valid
- choices are: 'open', 'closed', 'none', 'all'
- :arg from\\_: Starting offset (default: 0)
- :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
- providing text to a numeric field) should be ignored
- :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 refresh: Should the effected indexes be refreshed?
- :arg request_cache: Specify if request cache should be used for this
- request or not, defaults to index level setting
- :arg requests_per_second: The throttle for this request in sub-requests
- per second. -1 means no throttle., default 0
- :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 scroll_size: Size on the scroll request powering the
- update_by_query
- :arg search_timeout: Explicit timeout for each search request. Defaults
- to no timeout.
- :arg search_type: Search operation type, valid choices are:
- 'query_then_fetch', 'dfs_query_then_fetch'
- :arg size: Number of hits to return (default: 10)
- :arg slices: The number of slices this task should be divided into.
- Defaults to 1 meaning the task isn't sliced into subtasks., default
- 1
- :arg sort: A comma-separated list of : pairs
- :arg stats: Specific 'tag' of the request for logging and statistical
- purposes
- :arg terminate_after: The maximum number of documents to collect for
- each shard, upon reaching which the query execution will terminate
- early.
- :arg timeout: Time each individual bulk request should wait for shards
- that are unavailable., default '1m'
- :arg version: Specify whether to return document version as part of a
- hit
- :arg wait_for_active_shards: Sets the number of shard copies that must
- be active before proceeding with the delete by query operation.
- Defaults to 1, meaning the primary shard only. Set to `all` for all
- shard copies, otherwise set to any non-negative value less than or
- equal to the total number of copies for the shard (number of
- replicas + 1)
- :arg wait_for_completion: Should the request should block until the
- delete-by-query is complete., default True
- """
- for param in (index, body):
- if param in SKIP_IN_PATH:
- raise ValueError("Empty value passed for a required argument.")
- return self.transport.perform_request(
- "POST", _make_path(index, "_delete_by_query"), params=params, body=body
- )
-
- @query_params("requests_per_second")
- def delete_by_query_rethrottle(self, task_id, params=None):
- """
- ``_
-
- :arg task_id: The task id to rethrottle
- :arg requests_per_second: The throttle to set on this request in
- floating sub-requests per second. -1 means set no throttle.
- """
- if task_id in SKIP_IN_PATH:
- raise ValueError("Empty value passed for a required argument 'task_id'.")
- return self.transport.perform_request(
- "POST",
- _make_path("_delete_by_query", task_id, "_rethrottle"),
- params=params,
+ "GET", _make_path(index, doc_type, "_search"), params=params, body=body
)
@query_params(
@@ -1175,26 +1561,24 @@ class Elasticsearch(object):
)
def search_shards(self, index=None, params=None):
"""
- 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.
- ``_
+ Returns information about the indices and shards that a search request would be
+ executed against.
+ ``_
- :arg index: A list of index names to search, or a string containing a
- comma-separated list of index names to search; use `_all` or the
- empty string to perform the operation on all indices
+ :arg index: A comma-separated list of index names to search; 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 local: Return local information, do not retrieve the state from
- master node (default: false)
- :arg preference: Specify the node or shard the operation should be
- performed on (default: random)
+ :arg expand_wildcards: Whether to expand wildcard expression to
+ concrete indices that are open, closed or both. Valid choices: open,
+ closed, none, all Default: open
+ :arg ignore_unavailable: Whether specified concrete indices
+ should be ignored when unavailable (missing or closed)
+ :arg local: Return local information, do not retrieve the state
+ from master node (default: false)
+ :arg preference: Specify the node or shard the operation should
+ be performed on (default: random)
:arg routing: Specific routing value
"""
return self.transport.perform_request(
@@ -1203,372 +1587,68 @@ class Elasticsearch(object):
@query_params(
"allow_no_indices",
- "ccs_minimize_roundtrips",
"expand_wildcards",
"explain",
+ "ignore_throttled",
"ignore_unavailable",
"preference",
"profile",
- "routing",
"rest_total_hits_as_int",
+ "routing",
"scroll",
"search_type",
"typed_keys",
)
- def search_template(self, index=None, body=None, params=None):
+ def search_template(self, body, index=None, doc_type=None, params=None):
"""
- A query that accepts a query template and a map of key/value pairs to
- fill in template parameters.
- ``_
+ Allows to use the Mustache language to pre-render a search definition.
+ ``_
- :arg index: A list of index names to search, or a string containing a
- comma-separated list of index names to search; use `_all` or the
- empty string to perform the operation on all indices
:arg body: The search definition template and its params
+ :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 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 ccs_minimize_roundtrips: Indicates whether network round-trips
- should be minimized as part of cross-cluster search requests
- execution, default 'true'
- :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 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
- performed on (default: random)
+ :arg expand_wildcards: Whether to expand wildcard expression to
+ concrete indices that are open, closed or both. Valid choices: open,
+ closed, none, all Default: open
+ :arg explain: Specify whether to return detailed information
+ about score computation as part of a hit
+ :arg ignore_throttled: Whether specified concrete, expanded or
+ aliased indices should be ignored when throttled
+ :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 performed on (default: random)
:arg profile: Specify whether to profile the query execution
+ :arg rest_total_hits_as_int: Indicates whether hits.total should
+ be rendered as an integer or an object in the rest search response
:arg routing: A comma-separated list of specific routing values
- :arg rest_total_hits_as_int: Indicates whether hits.total should be
- rendered as an integer or an object in the rest search response,
- default False
- :arg scroll: Specify how long a consistent view of the index should be
- maintained for scrolled search
- :arg search_type: Search operation type, valid choices are:
- 'query_then_fetch', 'query_and_fetch', 'dfs_query_then_fetch',
- 'dfs_query_and_fetch'
- :arg typed_keys: Specify whether aggregation and suggester names should
- be prefixed by their respective types in the response
- """
- return self.transport.perform_request(
- "GET", _make_path(index, "_search", "template"), params=params, body=body
- )
-
- @query_params(
- "_source",
- "_source_excludes",
- "_source_includes",
- "analyze_wildcard",
- "analyzer",
- "default_operator",
- "df",
- "lenient",
- "parent",
- "preference",
- "q",
- "routing",
- "stored_fields",
- )
- def explain(self, index, id, doc_type="_doc", body=None, params=None):
- """
- The explain api computes a score explanation for a query and a specific
- document. This can give useful feedback whether a document matches or
- didn't match a specific query.
- ``_
-
- :arg index: The name of the index
- :arg id: The document ID
- :arg body: The query definition using the Query DSL
- :arg _source: True or false to return the _source field or not, or a
- list of fields to return
- :arg _source_excludes: A list of fields to exclude from the returned
- _source field
- :arg _source_includes: A list of fields to extract and return from the
- _source field
- :arg analyze_wildcard: Specify whether wildcards and prefix queries in
- 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', valid choices are: 'AND', 'OR'
- :arg df: The default field for query string query (default: _all)
- :arg lenient: Specify whether format-based query failures (such as
- providing text to a numeric field) should be ignored
- :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 stored_fields: A comma-separated list of stored fields to return in
- the response
- """
- for param in (index, id):
- if param in SKIP_IN_PATH:
- raise ValueError("Empty value passed for a required argument.")
- return self.transport.perform_request(
- "GET", _make_path(index, doc_type, id, "_explain"), params=params, body=body
- )
-
- @query_params("scroll", "rest_total_hits_as_int")
- def scroll(self, body=None, scroll_id=None, params=None):
- """
- Scroll a search request created by specifying the scroll parameter.
- ``_
-
- :arg scroll_id: The scroll ID
- :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
- :arg rest_total_hits_as_int: This parameter is used to restore the total hits as a number
- in the response. This param is added version 6.x to handle mixed cluster queries where nodes
- are in multiple versions (7.0 and 6.latest)
- """
- if scroll_id in SKIP_IN_PATH and body in SKIP_IN_PATH:
- raise ValueError("You need to supply scroll_id or body.")
- elif scroll_id and not body:
- body = {"scroll_id": scroll_id}
- elif scroll_id:
- params["scroll_id"] = scroll_id
-
- return self.transport.perform_request(
- "GET", "/_search/scroll", params=params, body=body
- )
-
- @query_params()
- def clear_scroll(self, scroll_id=None, body=None, params=None):
- """
- Clear the scroll request created by specifying the scroll parameter to
- search.
- ``_
-
- :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
- """
- if scroll_id in SKIP_IN_PATH and body in SKIP_IN_PATH:
- raise ValueError("You need to supply scroll_id or body.")
- elif scroll_id and not body:
- body = {"scroll_id": [scroll_id]}
- elif scroll_id:
- params["scroll_id"] = scroll_id
-
- return self.transport.perform_request(
- "DELETE", "/_search/scroll", params=params, body=body
- )
-
- @query_params(
- "if_seq_no",
- "if_primary_term",
- "parent",
- "refresh",
- "routing",
- "timeout",
- "version",
- "version_type",
- "wait_for_active_shards",
- )
- def delete(self, index, id, doc_type="_doc", params=None):
- """
- Delete a typed JSON document from a specific index based on its id.
- ``_
-
- :arg index: The name of the index
- :arg id: The document ID
- :arg if_primary_term: only perform the delete operation if the last
- operation that has changed the document has the specified primary
- term
- :arg if_seq_no: only perform the delete operation if the last operation
- that has changed the document has the specified sequence number
- :arg parent: ID of parent document
- :arg refresh: If `true` then refresh the effected shards to make this
- operation visible to search, if `wait_for` then wait for a refresh
- to make this operation visible to search, if `false` (the default)
- then do nothing with refreshes., valid choices are: 'true', 'false',
- 'wait_for'
- :arg routing: Specific routing value
- :arg timeout: Explicit operation timeout
- :arg version: Explicit version number for concurrency control
- :arg version_type: Specific version type, valid choices are: 'internal',
- 'external', 'external_gte', 'force'
- :arg wait_for_active_shards: Sets the number of shard copies that must
- be active before proceeding with the delete operation. Defaults to
- 1, meaning the primary shard only. Set to `all` for all shard
- copies, otherwise set to any non-negative value less than or equal
- to the total number of copies for the shard (number of replicas + 1)
- """
- for param in (index, id):
- if param in SKIP_IN_PATH:
- raise ValueError("Empty value passed for a required argument.")
- return self.transport.perform_request(
- "DELETE", _make_path(index, doc_type, id), params=params
- )
-
- @query_params(
- "allow_no_indices",
- "analyze_wildcard",
- "analyzer",
- "default_operator",
- "df",
- "expand_wildcards",
- "ignore_unavailable",
- "ignore_throttled",
- "lenient",
- "min_score",
- "preference",
- "q",
- "routing",
- "terminate_after",
- )
- def count(self, doc_type=None, index=None, body=None, params=None):
- """
- Execute a query and get the number of matches for that query.
- ``_
-
- :arg index: A list of index names or a string containing a
- comma-separated list of index names to restrict the results to
- :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)
- :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', 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', valid
- choices are: 'open', 'closed', 'none', 'all'
- :arg ignore_unavailable: Whether specified concrete indices should be
- ignored when unavailable (missing or closed)
- :arg ignore_throttled: Whether specified concrete, expanded or aliased
- indices should be ignored when throttled
- :arg lenient: Specify whether format-based query failures (such as
- providing text to a numeric field) should be ignored
- :arg min_score: Include only documents with a specific `_score` value in
- the result
- :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
- """
- if not index:
- index = "_all"
-
- return self.transport.perform_request(
- "GET", _make_path(index, doc_type, "_count"), params=params, body=body
- )
-
- @query_params(
- "_source",
- "_source_excludes",
- "_source_includes",
- "fields",
- "pipeline",
- "refresh",
- "routing",
- "timeout",
- "wait_for_active_shards",
- )
- def bulk(self, body, doc_type=None, index=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),
- separated by newlines
- :arg index: Default index for items which don't provide one
- :arg _source: True or false to return the _source field or not, or
- default list of fields to return, can be overridden on each sub-
- request
- :arg _source_excludes: Default list of fields to exclude from the
- returned _source field, can be overridden on each sub-request
- :arg _source_includes: Default list of fields to extract and return from
- the _source field, can be overridden on each sub-request
- :arg fields: Default comma-separated list of fields to return in the
- response for updates, can be overridden on each sub-request
- :arg pipeline: The pipeline id to preprocess incoming documents with
- :arg refresh: If `true` then refresh the effected shards to make this
- operation visible to search, if `wait_for` then wait for a refresh
- to make this operation visible to search, if `false` (the default)
- then do nothing with refreshes., valid choices are: 'true', 'false',
- 'wait_for'
- :arg routing: Specific routing value
- :arg timeout: Explicit operation timeout
- :arg wait_for_active_shards: Sets the number of shard copies that must
- be active before proceeding with the bulk operation. Defaults to 1,
- meaning the primary shard only. Set to `all` for all shard copies,
- otherwise set to any non-negative value less than or equal to the
- total number of copies for the shard (number of replicas + 1)
+ :arg scroll: Specify how long a consistent view of the index
+ should be maintained for scrolled search
+ :arg search_type: Search operation type Valid choices:
+ query_then_fetch, query_and_fetch, dfs_query_then_fetch,
+ dfs_query_and_fetch
+ :arg typed_keys: Specify whether aggregation and suggester names
+ should be prefixed by their respective types in the response
"""
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")
- return self.transport.perform_request(
- "POST",
- _make_path(index, doc_type, "_bulk"),
- params=params,
- body=self._bulk_body(body),
- headers={"content-type": "application/x-ndjson"},
- )
- @query_params(
- "ccs_minimize_roundtrips",
- "max_concurrent_searches",
- "max_concurrent_shard_requests",
- "pre_filter_shard_size",
- "rest_total_hits_as_int",
- "search_type",
- "typed_keys",
- )
- def msearch(self, body, index=None, params=None):
- """
- Execute several search requests within the same API.
- ``_
-
- :arg body: The request definitions (metadata-search request definition
- pairs), separated by newlines
- :arg index: A list of index names, or a string containing a
- comma-separated list of index names, to use as the default
- :arg ccs_minimize_roundtrips: Indicates whether network round-trips
- should be minimized as part of cross-cluster search requests
- execution, default 'true'
- :arg max_concurrent_searches: Controls the maximum number of concurrent
- searches the multi search api will execute
- :arg pre_filter_shard_size: A threshold that enforces a pre-filter
- roundtrip to prefilter search shards based on query rewriting if
- the number of shards the search request expands to exceeds the
- threshold. This filter roundtrip can limit the number of shards
- significantly if for instance a shard can not match any documents
- based on it's rewrite method ie. if date filters are mandatory to
- match but the shard bounds and the query are disjoint., default 128
- :arg search_type: Search operation type, valid choices are:
- 'query_then_fetch', 'query_and_fetch', 'dfs_query_then_fetch',
- 'dfs_query_and_fetch'
- :arg typed_keys: Specify whether aggregation and suggester names should
- be prefixed by their respective types in the response
- """
- if body in SKIP_IN_PATH:
- raise ValueError("Empty value passed for a required argument 'body'.")
return self.transport.perform_request(
"GET",
- _make_path(index, "_msearch"),
+ _make_path(index, doc_type, "_search", "template"),
params=params,
- body=self._bulk_body(body),
- headers={"content-type": "application/x-ndjson"},
+ body=body,
)
@query_params(
"field_statistics",
"fields",
"offsets",
- "parent",
"payloads",
"positions",
"preference",
@@ -1578,45 +1658,42 @@ class Elasticsearch(object):
"version",
"version_type",
)
- def termvectors(self, index, doc_type="_doc", id=None, body=None, params=None):
+ def termvectors(self, index, body=None, doc_type=None, id=None, params=None):
"""
- Returns information and statistics on terms in the fields of a
- particular document. The document could be stored in the index or
- 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.
- ``_
+ Returns information and statistics about terms in the fields of a particular
+ document.
+ ``_
:arg index: The index in which the document resides.
- :arg id: The id of the document, when not specified a doc param should
- be supplied.
- :arg body: Define parameters and or supply a document to get termvectors
- for. See documentation.
- :arg field_statistics: Specifies if document count, sum of document
- frequencies and sum of total term frequencies should be returned.,
- default True
+ :arg body: Define parameters and or supply a document to get
+ termvectors for. See documentation.
+ :arg doc_type: The type of the document.
+ :arg id: The id of the document, when not specified a doc param
+ should be supplied.
+ :arg field_statistics: Specifies if document count, sum of
+ document frequencies and sum of total term frequencies should be
+ returned. Default: True
:arg fields: A comma-separated list of fields to return.
- :arg offsets: Specifies if term offsets should be returned., default
- True
- :arg parent: Parent id of documents.
- :arg payloads: Specifies if term payloads should be returned., default
- True
- :arg positions: Specifies if term positions should be returned., default
- True
- :arg preference: Specify the node or shard the operation should be
- performed on (default: random).
- :arg realtime: Specifies if request is real-time as opposed to near-
- real-time (default: true).
+ :arg offsets: Specifies if term offsets should be returned.
+ Default: True
+ :arg payloads: Specifies if term payloads should be returned.
+ Default: True
+ :arg positions: Specifies if term positions should be returned.
+ Default: True
+ :arg preference: Specify the node or shard the operation should
+ be performed on (default: random).
+ :arg realtime: Specifies if request is real-time as opposed to
+ near-real-time (default: true).
:arg routing: Specific routing value.
- :arg term_statistics: Specifies if total term frequency and document
- frequency should be returned., default False
+ :arg term_statistics: Specifies if total term frequency and
+ document frequency should be returned.
:arg version: Explicit version number for concurrency control
- :arg version_type: Specific version type, valid choices are: 'internal',
- 'external', 'external_gte', 'force'
+ :arg version_type: Specific version type Valid choices:
+ internal, external, external_gte, force
"""
- for param in (index,):
- if param in SKIP_IN_PATH:
- raise ValueError("Empty value passed for a required argument.")
+ if index in SKIP_IN_PATH:
+ raise ValueError("Empty value passed for a required argument 'index'.")
+
return self.transport.perform_request(
"GET",
_make_path(index, doc_type, id, "_termvectors"),
@@ -1625,245 +1702,213 @@ class Elasticsearch(object):
)
@query_params(
- "field_statistics",
- "fields",
- "ids",
- "offsets",
- "parent",
- "payloads",
- "positions",
- "preference",
- "realtime",
+ "_source",
+ "_source_excludes",
+ "_source_includes",
+ "if_primary_term",
+ "if_seq_no",
+ "lang",
+ "refresh",
+ "retry_on_conflict",
"routing",
- "term_statistics",
+ "timeout",
+ "wait_for_active_shards",
+ )
+ def update(self, index, id, body, doc_type=None, params=None):
+ """
+ Updates a document with a script or partial document.
+ ``_
+
+ :arg index: The name of the index
+ :arg id: Document ID
+ :arg body: The request definition requires either `script` or
+ partial `doc`
+ :arg doc_type: The type of the document
+ :arg _source: True or false to return the _source field or not,
+ or a list of fields to return
+ :arg _source_excludes: A list of fields to exclude from the
+ returned _source field
+ :arg _source_includes: A list of fields to extract and return
+ from the _source field
+ :arg if_primary_term: only perform the update operation if the
+ last operation that has changed the document has the specified primary
+ term
+ :arg if_seq_no: only perform the update operation if the last
+ operation that has changed the document has the specified sequence
+ number
+ :arg lang: The script language (default: painless)
+ :arg refresh: If `true` then refresh the effected shards to make
+ this operation visible to search, if `wait_for` then wait for a refresh
+ to make this operation visible to search, if `false` (the default) then
+ do nothing with refreshes. Valid choices: true, false, wait_for
+ :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 timeout: Explicit operation timeout
+ :arg wait_for_active_shards: Sets the number of shard copies
+ that must be active before proceeding with the update operation.
+ Defaults to 1, meaning the primary shard only. Set to `all` for all
+ shard copies, otherwise set to any non-negative value less than or equal
+ to the total number of copies for the shard (number of replicas + 1)
+ """
+ for param in (index, id, body):
+ if param in SKIP_IN_PATH:
+ raise ValueError("Empty value passed for a required argument.")
+
+ return self.transport.perform_request(
+ "POST", _make_path(index, doc_type, id, "_update"), params=params, body=body
+ )
+
+ @query_params(
+ "_source",
+ "_source_excludes",
+ "_source_includes",
+ "allow_no_indices",
+ "analyze_wildcard",
+ "analyzer",
+ "conflicts",
+ "default_operator",
+ "df",
+ "expand_wildcards",
+ "from_",
+ "ignore_unavailable",
+ "lenient",
+ "max_docs",
+ "pipeline",
+ "preference",
+ "q",
+ "refresh",
+ "request_cache",
+ "requests_per_second",
+ "routing",
+ "scroll",
+ "scroll_size",
+ "search_timeout",
+ "search_type",
+ "size",
+ "slices",
+ "sort",
+ "stats",
+ "terminate_after",
+ "timeout",
"version",
"version_type",
+ "wait_for_active_shards",
+ "wait_for_completion",
)
- def mtermvectors(self, doc_type=None, index=None, body=None, params=None):
+ def update_by_query(self, index, body=None, doc_type=None, params=None):
"""
- Multi termvectors API allows to get multiple termvectors based on an
- index, type and id.
- ``_
+ Performs an update on every document in the index without changing the source,
+ for example to pick up a mapping change.
+ ``_
- :arg index: The index in which the document resides.
- :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.
- Applies to all returned documents unless otherwise specified in body
- "params" or "docs"., default True
- :arg fields: A comma-separated list of fields to return. Applies to all
- returned documents unless otherwise specified in body "params" or
- "docs".
- :arg ids: A comma-separated list of documents ids. You must define ids
- as parameter or set "ids" or "docs" in the request body
- :arg offsets: Specifies if term offsets should be returned. Applies to
- all returned documents unless otherwise specified in body "params"
- or "docs"., default True
- :arg parent: Parent id of documents. Applies to all returned documents
- unless otherwise specified in body "params" or "docs".
- :arg payloads: Specifies if term payloads should be returned. Applies to
- all returned documents unless otherwise specified in body "params"
- or "docs"., default True
- :arg positions: Specifies if term positions should be returned. Applies
- to all returned documents unless otherwise specified in body
- "params" or "docs"., default True
- :arg preference: Specify the node or shard the operation should be
- performed on (default: random) .Applies to all returned documents
- unless otherwise specified in body "params" or "docs".
- :arg realtime: Specifies if requests are real-time as opposed to near-
- real-time (default: true).
- :arg routing: Specific routing value. Applies to all returned documents
- unless otherwise specified in body "params" or "docs".
- :arg term_statistics: Specifies if total term frequency and document
- 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'
+ :arg index: A comma-separated list of index names to search; use
+ `_all` or empty string to perform the operation on all indices
+ :arg body: The search definition using the Query DSL
+ :arg doc_type: A comma-separated list of document types to
+ search; leave empty to perform the operation on all types
+ :arg _source: True or false to return the _source field or not,
+ or a list of fields to return
+ :arg _source_excludes: A list of fields to exclude from the
+ returned _source field
+ :arg _source_includes: 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 conflicts: What to do when the update by query hits version
+ conflicts? Valid choices: abort, proceed Default: abort
+ :arg default_operator: The default operator for query string
+ query (AND or OR) Valid choices: AND, OR Default: 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. Valid choices: open,
+ closed, none, all Default: open
+ :arg from_: Starting offset (default: 0)
+ :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 providing text to a numeric field) should be ignored
+ :arg max_docs: Maximum number of documents to process (default:
+ all documents)
+ :arg pipeline: Ingest pipeline to set on index requests made by
+ this action. (default: none)
+ :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 refresh: Should the effected indexes be refreshed?
+ :arg request_cache: Specify if request cache should be used for
+ this request or not, defaults to index level setting
+ :arg requests_per_second: The throttle to set on this request in
+ sub-requests per second. -1 means no throttle.
+ :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 scroll_size: Size on the scroll request powering the update
+ by query
+ :arg search_timeout: Explicit timeout for each search request.
+ Defaults to no timeout.
+ :arg search_type: Search operation type Valid choices:
+ query_then_fetch, dfs_query_then_fetch
+ :arg size: Deprecated, please use `max_docs` instead
+ :arg slices: The number of slices this task should be divided
+ into. Defaults to 1 meaning the task isn't sliced into subtasks.
+ Default: 1
+ :arg sort: A comma-separated list of : pairs
+ :arg stats: Specific 'tag' of the request for logging and
+ statistical purposes
+ :arg terminate_after: The maximum number of documents to collect
+ for each shard, upon reaching which the query execution will terminate
+ early.
+ :arg timeout: Time each individual bulk request should wait for
+ shards that are unavailable. Default: 1m
+ :arg version: Specify whether to return document version as part
+ of a hit
+ :arg version_type: Should the document increment the version
+ number (internal) on hit or not (reindex)
+ :arg wait_for_active_shards: Sets the number of shard copies
+ that must be active before proceeding with the update by query
+ operation. Defaults to 1, meaning the primary shard only. Set to `all`
+ for all shard copies, otherwise set to any non-negative value less than
+ or equal to the total number of copies for the shard (number of replicas
+ + 1)
+ :arg wait_for_completion: Should the request should block until
+ the update by query operation is complete. Default: True
"""
+ # from is a reserved word so it cannot be used, use from_ instead
+ if "from_" in params:
+ params["from"] = params.pop("from_")
+
+ if index in SKIP_IN_PATH:
+ raise ValueError("Empty value passed for a required argument 'index'.")
+
return self.transport.perform_request(
- "GET",
- _make_path(index, doc_type, "_mtermvectors"),
+ "POST",
+ _make_path(index, doc_type, "_update_by_query"),
params=params,
body=body,
)
- @query_params("master_timeout", "timeout")
- def put_script(self, id, body, context=None, params=None):
+ @query_params("requests_per_second")
+ def update_by_query_rethrottle(self, task_id, params=None):
"""
- Create a script in given language with specified ID.
- ``_
+ Changes the number of requests per second for a particular Update By Query
+ operation.
+ ``_
+
+ :arg task_id: The task id to rethrottle
+ :arg requests_per_second: The throttle to set on this request in
+ floating sub-requests per second. -1 means set no throttle.
+ """
+ if task_id in SKIP_IN_PATH:
+ raise ValueError("Empty value passed for a required argument 'task_id'.")
- :arg id: Script ID
- :arg body: The document
- :arg master_timeout: Specify timeout for connection to master
- :arg timeout: Explicit operation timeout
- """
- for param in (id, body):
- if param in SKIP_IN_PATH:
- raise ValueError("Empty value passed for a required argument.")
return self.transport.perform_request(
- "PUT", _make_path("_scripts", id, context), params=params, body=body
- )
-
- @query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable")
- def rank_eval(self, body, index=None, params=None):
- """
- ``_
-
- :arg body: The ranking evaluation search definition, including search
- requests, document ratings and ranking metric definition.
- :arg index: A comma-separated list of index names to search; 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)
- """
- if body in SKIP_IN_PATH:
- raise ValueError("Empty value passed for a required argument 'body'.")
- return self.transport.perform_request(
- "GET", _make_path(index, "_rank_eval"), params=params, body=body
- )
-
- @query_params("master_timeout")
- def get_script(self, id, params=None):
- """
- Retrieve a script from the API.
- ``_
-
- :arg id: Script ID
- :arg master_timeout: Specify timeout for connection to master
- """
- if id in SKIP_IN_PATH:
- raise ValueError("Empty value passed for a required argument 'id'.")
- return self.transport.perform_request(
- "GET", _make_path("_scripts", id), params=params
- )
-
- @query_params("master_timeout", "timeout")
- def delete_script(self, id, params=None):
- """
- Remove a stored script from elasticsearch.
- ``_
-
- :arg id: Script ID
- :arg master_timeout: Specify timeout for connection to master
- :arg timeout: Explicit operation timeout """
- if id in SKIP_IN_PATH:
- raise ValueError("Empty value passed for a required argument 'id'.")
- return self.transport.perform_request(
- "DELETE", _make_path("_scripts", id), params=params
- )
-
- @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
- """
- return self.transport.perform_request(
- "GET", _make_path("_render", "template", id), params=params, body=body
- )
-
- @query_params("context")
- def scripts_painless_context(self, params=None):
- """
- `<>`_
-
- :arg context: Select a specific context to retrieve API information
- about
- """
- return self.transport.perform_request(
- "GET", "/_scripts/painless/_context", params=params
- )
-
- @query_params()
- def scripts_painless_execute(self, body=None, params=None):
- """
- ``_
-
- :arg body: The script to execute
- """
- return self.transport.perform_request(
- "GET", "/_scripts/painless/_execute", params=params, body=body
- )
-
- @query_params(
- "ccs_minimize_roundtrips",
- "max_concurrent_searches",
- "search_type",
- "typed_keys",
- )
- def msearch_template(self, body, index=None, params=None):
- """
- The /_search/template endpoint allows to use the mustache language to
- pre render search requests, before they are executed and fill existing
- templates with template parameters.
- ``_
-
- :arg body: The request definitions (metadata-search request definition
- pairs), separated by newlines
- :arg index: A list of index names, or a string containing a
- comma-separated list of index names, to use as the default
- :arg ccs_minimize_roundtrips: Indicates whether network round-trips
- should be minimized as part of cross-cluster search requests
- execution, default 'true'
- :arg max_concurrent_searches: Controls the maximum number of concurrent
- searches the multi search api will execute
- :arg search_type: Search operation type, valid choices are:
- 'query_then_fetch', 'query_and_fetch', 'dfs_query_then_fetch',
- 'dfs_query_and_fetch'
- :arg typed_keys: Specify whether aggregation and suggester names should
- be prefixed by their respective types in the response
- """
- if body in SKIP_IN_PATH:
- raise ValueError("Empty value passed for a required argument 'body'.")
- return self.transport.perform_request(
- "GET",
- _make_path(index, "_msearch", "template"),
+ "POST",
+ _make_path("_update_by_query", task_id, "_rethrottle"),
params=params,
- body=self._bulk_body(body),
- headers={"content-type": "application/x-ndjson"},
- )
-
- @query_params(
- "allow_no_indices",
- "expand_wildcards",
- "fields",
- "ignore_unavailable",
- "include_unmapped",
- )
- def field_caps(self, index=None, body=None, params=None):
- """
- The field capabilities API allows to retrieve the capabilities of fields among multiple indices.
- ``_
-
- :arg index: A list of index names, or a string containing a
- comma-separated list of index names; use `_all` or the empty string
- to perform the operation on all indices
- :arg body: Field json objects containing an array of field names
- :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 fields: A comma-separated list of field names
- :arg ignore_unavailable: Whether specified concrete indices should be
- ignored when unavailable (missing or closed)
- :arg include_unmapped: Indicates whether unmapped fields should be
- included in the response., default False
- """
- return self.transport.perform_request(
- "GET", _make_path(index, "_field_caps"), params=params, body=body
)
diff --git a/elasticsearch/client/cat.py b/elasticsearch/client/cat.py
index 46ac8e8b..515483e4 100644
--- a/elasticsearch/client/cat.py
+++ b/elasticsearch/client/cat.py
@@ -2,23 +2,23 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
class CatClient(NamespacedClient):
- @query_params("format", "h", "help", "local", "master_timeout", "s", "v")
+ @query_params("format", "h", "help", "local", "s", "v")
def aliases(self, name=None, params=None):
"""
-
- ``_
+ Shows information about currently configured aliases to indices including
+ filter and routing infos.
+ ``_
:arg name: A comma-separated list of alias names to return
- :arg format: a short version of the Accept header, e.g. json, yaml
+ :arg format: a short version of the Accept header, e.g. json,
+ yaml
:arg h: Comma-separated list of column names to display
- :arg help: Return help information, default False
- :arg 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 s: Comma-separated list of column names or column aliases to sort
- by
- :arg v: Verbose mode. Display column headers, default False
+ :arg help: Return help information
+ :arg local: Return local information, do not retrieve the state
+ from master node (default: false)
+ :arg s: Comma-separated list of column names or column aliases
+ to sort by
+ :arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request(
"GET", _make_path("_cat", "aliases", name), params=params
@@ -27,123 +27,128 @@ class CatClient(NamespacedClient):
@query_params("bytes", "format", "h", "help", "local", "master_timeout", "s", "v")
def allocation(self, node_id=None, params=None):
"""
- Allocation provides a snapshot of how shards have located around the
- cluster and the state of disk usage.
- ``_
+ Provides a snapshot of how many shards are allocated to each data node and how
+ much disk space they are using.
+ ``_
- :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, valid choices are:
- 'b', 'k', 'kb', 'm', 'mb', 'g', 'gb', 't', 'tb', 'p', 'pb'
- :arg format: a short version of the Accept header, e.g. json, yaml
+ :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 Valid
+ choices: b, k, kb, m, mb, g, gb, t, tb, p, pb
+ :arg format: a short version of the Accept header, e.g. json,
+ yaml
:arg h: Comma-separated list of column names to display
- :arg help: Return help information, default False
- :arg 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 s: Comma-separated list of column names or column aliases to sort
- by
- :arg v: Verbose mode. Display column headers, default False
+ :arg help: Return help information
+ :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 s: Comma-separated list of column names or column aliases
+ to sort by
+ :arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request(
"GET", _make_path("_cat", "allocation", node_id), params=params
)
- @query_params("format", "h", "help", "local", "master_timeout", "s", "v")
+ @query_params("format", "h", "help", "s", "v")
def count(self, index=None, params=None):
"""
- Count provides quick access to the document count of the entire cluster,
- or individual indices.
- ``_
+ 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
- :arg format: a short version of the Accept header, e.g. json, yaml
+ :arg index: A comma-separated list of index names to limit the
+ returned information
+ :arg format: a short version of the Accept header, e.g. json,
+ yaml
:arg h: Comma-separated list of column names to display
- :arg help: Return help information, default False
- :arg 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 s: Comma-separated list of column names or column aliases to sort
- by
- :arg v: Verbose mode. Display column headers, default False
+ :arg help: Return help information
+ :arg s: Comma-separated list of column names or column aliases
+ to sort by
+ :arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request(
"GET", _make_path("_cat", "count", index), params=params
)
- @query_params("format", "h", "help", "local", "master_timeout", "s", "ts", "v")
+ @query_params("format", "h", "help", "s", "time", "ts", "v")
def health(self, params=None):
"""
- health is a terse, one-line representation of the same information from
- :meth:`~elasticsearch.client.cluster.ClusterClient.health` API
- ``_
+ Returns a concise representation of the cluster health.
+ ``_
- :arg format: a short version of the Accept header, e.g. json, yaml
+ :arg format: a short version of the Accept header, e.g. json,
+ yaml
:arg h: Comma-separated list of column names to display
- :arg help: Return help information, default False
- :arg 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 s: Comma-separated list of column names or column aliases to sort
- by
- :arg ts: Set to false to disable timestamping, default True
- :arg v: Verbose mode. Display column headers, default False
+ :arg help: Return help information
+ :arg s: Comma-separated list of column names or column aliases
+ to sort by
+ :arg time: The unit in which to display time values Valid
+ choices: d (Days), h (Hours), m (Minutes), s (Seconds), ms
+ (Milliseconds), micros (Microseconds), nanos (Nanoseconds)
+ :arg ts: Set to false to disable timestamping Default: True
+ :arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request("GET", "/_cat/health", params=params)
@query_params("help", "s")
def help(self, params=None):
"""
- A simple help for the cat api.
- ``_
+ Returns help for the Cat APIs.
+ ``_
- :arg help: Return help information, default False
- :arg s: Comma-separated list of column names or column aliases to sort
- by
+ :arg help: Return help information
+ :arg s: Comma-separated list of column names or column aliases
+ to sort by
"""
return self.transport.perform_request("GET", "/_cat", params=params)
@query_params(
"bytes",
- "size",
"format",
"h",
"health",
"help",
+ "include_unloaded_segments",
"local",
"master_timeout",
"pri",
"s",
+ "time",
"v",
)
def indices(self, index=None, params=None):
"""
- The indices command provides a cross-section of each index.
- ``_
+ Returns information about indices: number of primaries and replicas, document
+ counts, disk size, ...
+ ``_
- :arg index: A comma-separated list of index names to limit the returned
- information
- :arg bytes: The unit in which to display byte values, valid choices are:
- 'b', 'k', 'm', 'g'
- :arg format: a short version of the Accept header, e.g. json, yaml
+ :arg index: A comma-separated list of index names to limit the
+ returned information
+ :arg bytes: The unit in which to display byte values Valid
+ choices: b, k, m, g
+ :arg format: a short version of the Accept header, e.g. json,
+ yaml
:arg h: Comma-separated list of column names to display
- :arg health: A health status ("green", "yellow", or "red" to filter only
- indices matching the specified health status, default None, valid
- choices are: 'green', 'yellow', 'red'
- :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 pri: Set to true to return stats only for primary shards, default
- False
- :arg s: Comma-separated list of column names or column aliases to sort
- by
- :arg v: Verbose mode. Display column headers, default False
+ :arg health: A health status ("green", "yellow", or "red" to
+ filter only indices matching the specified health status Valid choices:
+ green, yellow, red
+ :arg help: Return help information
+ :arg include_unloaded_segments: If set to true segment stats
+ will include stats for segments that are not currently loaded into
+ memory
+ :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 pri: Set to true to return stats only for primary shards
+ :arg s: Comma-separated list of column names or column aliases
+ to sort by
+ :arg time: The unit in which to display time values Valid
+ choices: d (Days), h (Hours), m (Minutes), s (Seconds), ms
+ (Milliseconds), micros (Microseconds), nanos (Nanoseconds)
+ :arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request(
"GET", _make_path("_cat", "indices", index), params=params
@@ -152,134 +157,176 @@ class CatClient(NamespacedClient):
@query_params("format", "h", "help", "local", "master_timeout", "s", "v")
def master(self, params=None):
"""
- Displays the master's node ID, bound IP address, and node name.
- ``_
+ Returns information about the master node.
+ ``_
- :arg format: a short version of the Accept header, e.g. json, yaml
+ :arg format: a short version of the Accept header, e.g. json,
+ yaml
:arg h: Comma-separated list of column names to display
- :arg help: Return help information, default False
- :arg 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 s: Comma-separated list of column names or column aliases to sort
- by
- :arg v: Verbose mode. Display column headers, default False
+ :arg help: Return help information
+ :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 s: Comma-separated list of column names or column aliases
+ to sort by
+ :arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request("GET", "/_cat/master", params=params)
- @query_params("format", "full_id", "h", "help", "local", "master_timeout", "s", "v")
+ @query_params(
+ "bytes",
+ "format",
+ "full_id",
+ "h",
+ "help",
+ "local",
+ "master_timeout",
+ "s",
+ "time",
+ "v",
+ )
def nodes(self, params=None):
"""
- The nodes command shows the cluster topology.
- ``_
+ Returns basic statistics about performance of cluster nodes.
+ ``_
- :arg format: a short version of the Accept header, e.g. json, yaml
- :arg full_id: Return the full node ID instead of the shortened version
- (default: false)
+ :arg bytes: The unit in which to display byte values Valid
+ choices: b, k, kb, m, mb, g, gb, t, tb, p, pb
+ :arg format: a short version of the Accept header, e.g. json,
+ yaml
+ :arg full_id: Return the full node ID instead of the shortened
+ version (default: false)
: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 s: Comma-separated list of column names or column aliases to sort
- by
- :arg v: Verbose mode. Display column headers, default False
+ :arg help: Return help information
+ :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 s: Comma-separated list of column names or column aliases
+ to sort by
+ :arg time: The unit in which to display time values Valid
+ choices: d (Days), h (Hours), m (Minutes), s (Seconds), ms
+ (Milliseconds), micros (Microseconds), nanos (Nanoseconds)
+ :arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request("GET", "/_cat/nodes", params=params)
@query_params(
- "bytes", "time", "size", "format", "h", "help", "master_timeout", "s", "v"
+ "active_only",
+ "bytes",
+ "detailed",
+ "format",
+ "h",
+ "help",
+ "index",
+ "s",
+ "time",
+ "v",
)
def recovery(self, index=None, params=None):
"""
- recovery is a view of shard replication.
- ``_
+ Returns information about index shard recoveries, both on-going completed.
+ ``_
- :arg index: A comma-separated list of index names to limit the returned
- information
- :arg bytes: The unit in which to display byte values, valid choices are:
- 'b', 'k', 'kb', 'm', 'mb', 'g', 'gb', 't', 'tb', 'p', 'pb'
- :arg format: a short version of the Accept header, e.g. json, yaml
+ :arg index: Comma-separated list or wildcard expression of index
+ names to limit the returned information
+ :arg active_only: If `true`, the response only includes ongoing
+ shard recoveries
+ :arg bytes: The unit in which to display byte values Valid
+ choices: b, k, kb, m, mb, g, gb, t, tb, p, pb
+ :arg detailed: If `true`, the response includes detailed
+ information about shard recoveries
+ :arg format: a short version of the Accept header, e.g. json,
+ yaml
:arg h: Comma-separated list of column names to display
- :arg help: Return help information, default False
- :arg master_timeout: Explicit operation timeout for connection to master
- node
- :arg s: Comma-separated list of column names or column aliases to sort
- by
- :arg v: Verbose mode. Display column headers, default False
+ :arg help: Return help information
+ :arg index: Comma-separated list or wildcard expression of index
+ names to limit the returned information
+ :arg s: Comma-separated list of column names or column aliases
+ to sort by
+ :arg time: The unit in which to display time values Valid
+ choices: d (Days), h (Hours), m (Minutes), s (Seconds), ms
+ (Milliseconds), micros (Microseconds), nanos (Nanoseconds)
+ :arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request(
"GET", _make_path("_cat", "recovery", index), params=params
)
@query_params(
- "bytes", "size", "format", "h", "help", "local", "master_timeout", "s", "v"
+ "bytes", "format", "h", "help", "local", "master_timeout", "s", "time", "v"
)
def shards(self, index=None, params=None):
"""
- The shards command is the detailed view of what nodes contain which shards.
- ``_
+ Provides a detailed view of shard allocation on nodes.
+ ``_
- :arg index: A comma-separated list of index names to limit the returned
- information
- :arg bytes: The unit in which to display byte values, valid choices are:
- 'b', 'k', 'kb', 'm', 'mb', 'g', 'gb', 't', 'tb', 'p', 'pb'
- :arg format: a short version of the Accept header, e.g. json, yaml
+ :arg index: A comma-separated list of index names to limit the
+ returned information
+ :arg bytes: The unit in which to display byte values Valid
+ choices: b, k, kb, m, mb, g, gb, t, tb, p, pb
+ :arg format: a short version of the Accept header, e.g. json,
+ yaml
:arg h: Comma-separated list of column names to display
- :arg help: Return help information, default False
- :arg 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 s: Comma-separated list of column names or column aliases to sort
- by
- :arg v: Verbose mode. Display column headers, default False
+ :arg help: Return help information
+ :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 s: Comma-separated list of column names or column aliases
+ to sort by
+ :arg time: The unit in which to display time values Valid
+ choices: d (Days), h (Hours), m (Minutes), s (Seconds), ms
+ (Milliseconds), micros (Microseconds), nanos (Nanoseconds)
+ :arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request(
"GET", _make_path("_cat", "shards", index), params=params
)
- @query_params("bytes", "size", "format", "h", "help", "s", "v")
+ @query_params("bytes", "format", "h", "help", "s", "v")
def segments(self, index=None, params=None):
"""
- The segments command is the detailed view of Lucene segments per index.
- ``_
+ Provides low-level information about the segments in the shards of an 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, valid choices are:
- 'b', 'k', 'kb', 'm', 'mb', 'g', 'gb', 't', 'tb', 'p', 'pb'
- :arg format: a short version of the Accept header, e.g. json, yaml
+ :arg index: A comma-separated list of index names to limit the
+ returned information
+ :arg bytes: The unit in which to display byte values Valid
+ choices: b, k, kb, m, mb, g, gb, t, tb, p, pb
+ :arg format: a short version of the Accept header, e.g. json,
+ yaml
:arg h: Comma-separated list of column names to display
- :arg help: Return help information, default False
- :arg s: Comma-separated list of column names or column aliases to sort
- by
- :arg v: Verbose mode. Display column headers, default False
+ :arg help: Return help information
+ :arg s: Comma-separated list of column names or column aliases
+ to sort by
+ :arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request(
"GET", _make_path("_cat", "segments", index), params=params
)
- @query_params("format", "h", "help", "local", "master_timeout", "s", "v")
+ @query_params("format", "h", "help", "local", "master_timeout", "s", "time", "v")
def pending_tasks(self, params=None):
"""
- pending_tasks provides the same information as the
- :meth:`~elasticsearch.client.cluster.ClusterClient.pending_tasks` API
- in a convenient tabular format.
- ``_
+ Returns a concise representation of the cluster pending tasks.
+ ``_
- :arg format: a short version of the Accept header, e.g. json, yaml
+ :arg format: a short version of the Accept header, e.g. json,
+ yaml
:arg h: Comma-separated list of column names to display
- :arg help: Return help information, default False
- :arg 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 s: Comma-separated list of column names or column aliases to sort
- by
- :arg v: Verbose mode. Display column headers, default False
+ :arg help: Return help information
+ :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 s: Comma-separated list of column names or column aliases
+ to sort by
+ :arg time: The unit in which to display time values Valid
+ choices: d (Days), h (Hours), m (Minutes), s (Seconds), ms
+ (Milliseconds), micros (Microseconds), nanos (Nanoseconds)
+ :arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request(
"GET", "/_cat/pending_tasks", params=params
@@ -288,23 +335,25 @@ class CatClient(NamespacedClient):
@query_params("format", "h", "help", "local", "master_timeout", "s", "size", "v")
def thread_pool(self, thread_pool_patterns=None, params=None):
"""
- Get information about thread pools.
- ``_
+ Returns cluster-wide thread pool statistics per node. By default the active,
+ queue and rejected statistics are returned for all thread pools.
+ ``_
- :arg thread_pool_patterns: A comma-separated list of regular-expressions
- to filter the thread pools in the output
- :arg format: a short version of the Accept header, e.g. json, yaml
+ :arg thread_pool_patterns: A comma-separated list of regular-
+ expressions to filter the thread pools in the output
+ :arg format: a short version of the Accept header, e.g. json,
+ yaml
:arg h: Comma-separated list of column names to display
- :arg help: Return help information, default False
- :arg 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 s: Comma-separated list of column names or column aliases to sort
- by
- :arg size: The multiplier in which to display values, valid choices are:
- '', 'k', 'm', 'g', 't', 'p'
- :arg v: Verbose mode. Display column headers, default False
+ :arg help: Return help information
+ :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 s: Comma-separated list of column names or column aliases
+ to sort by
+ :arg size: The multiplier in which to display values Valid
+ choices: , k, m, g, t, p
+ :arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request(
"GET",
@@ -312,26 +361,26 @@ class CatClient(NamespacedClient):
params=params,
)
- @query_params("bytes", "format", "h", "help", "local", "master_timeout", "s", "v")
+ @query_params("bytes", "fields", "format", "h", "help", "s", "v")
def fielddata(self, fields=None, params=None):
"""
- Shows information about currently loaded fielddata on a per-node basis.
- ``_
+ Shows how much heap memory is currently being used by fielddata on every data
+ node in the cluster.
+ ``_
- :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', 'kb', 'm', 'mb', 'g', 'gb', 't', 'tb', 'p', 'pb'
- :arg format: a short version of the Accept header, e.g. json, yaml
+ :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: b, k, kb, m, mb, g, gb, t, tb, p, pb
+ :arg fields: A comma-separated list of fields to return in the
+ output
+ :arg format: a short version of the Accept header, e.g. json,
+ yaml
:arg h: Comma-separated list of column names to display
- :arg help: Return help information, default False
- :arg 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 s: Comma-separated list of column names or column aliases to sort
- by
- :arg v: Verbose mode. Display column headers, default False
+ :arg help: Return help information
+ :arg s: Comma-separated list of column names or column aliases
+ to sort by
+ :arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request(
"GET", _make_path("_cat", "fielddata", fields), params=params
@@ -340,85 +389,90 @@ class CatClient(NamespacedClient):
@query_params("format", "h", "help", "local", "master_timeout", "s", "v")
def plugins(self, params=None):
"""
+ Returns information about installed plugins across nodes node.
+ ``_
- ``_
-
- :arg format: a short version of the Accept header, e.g. json, yaml
+ :arg format: a short version of the Accept header, e.g. json,
+ yaml
:arg h: Comma-separated list of column names to display
- :arg help: Return help information, default False
- :arg 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 s: Comma-separated list of column names or column aliases to sort
- by
- :arg v: Verbose mode. Display column headers, default False
+ :arg help: Return help information
+ :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 s: Comma-separated list of column names or column aliases
+ to sort by
+ :arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request("GET", "/_cat/plugins", params=params)
@query_params("format", "h", "help", "local", "master_timeout", "s", "v")
def nodeattrs(self, params=None):
"""
+ Returns information about custom node attributes.
+ ``_
- ``_
-
- :arg format: a short version of the Accept header, e.g. json, yaml
+ :arg format: a short version of the Accept header, e.g. json,
+ yaml
:arg h: Comma-separated list of column names to display
- :arg help: Return help information, default False
- :arg 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 s: Comma-separated list of column names or column aliases to sort
- by
- :arg v: Verbose mode. Display column headers, default False
+ :arg help: Return help information
+ :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 s: Comma-separated list of column names or column aliases
+ to sort by
+ :arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request("GET", "/_cat/nodeattrs", params=params)
@query_params("format", "h", "help", "local", "master_timeout", "s", "v")
def repositories(self, params=None):
"""
+ Returns information about snapshot repositories registered in the cluster.
+ ``_
- ``_
-
- :arg format: a short version of the Accept header, e.g. json, yaml
+ :arg format: a short version of the Accept header, e.g. json,
+ yaml
:arg h: Comma-separated list of column names to display
- :arg help: Return help information, default False
- :arg 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 s: Comma-separated list of column names or column aliases to sort
- by
- :arg v: Verbose mode. Display column headers, default False
+ :arg help: Return help information
+ :arg local: Return local information, do not retrieve the state
+ from master node
+ :arg master_timeout: Explicit operation timeout for connection
+ to master node
+ :arg s: Comma-separated list of column names or column aliases
+ to sort by
+ :arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request(
"GET", "/_cat/repositories", params=params
)
@query_params(
- "format", "h", "help", "ignore_unavailable", "master_timeout", "s", "v"
+ "format", "h", "help", "ignore_unavailable", "master_timeout", "s", "time", "v"
)
- def snapshots(self, repository, params=None):
+ def snapshots(self, repository=None, params=None):
"""
+ Returns all snapshots in a specific repository.
+ ``_
- ``_
-
- :arg repository: Name of repository from which to fetch the snapshot
- information
- :arg format: a short version of the Accept header, e.g. json, yaml
+ :arg repository: Name of repository from which to fetch the
+ snapshot information
+ :arg format: a short version of the Accept header, e.g. json,
+ yaml
:arg h: Comma-separated list of column names to display
- :arg help: Return help information, default False
- :arg ignore_unavailable: Set to true to ignore unavailable snapshots,
- default False
- :arg master_timeout: Explicit operation timeout for connection to master
- node
- :arg s: Comma-separated list of column names or column aliases to sort
- by
- :arg v: Verbose mode. Display column headers, default False
+ :arg help: Return help information
+ :arg ignore_unavailable: Set to true to ignore unavailable
+ snapshots
+ :arg master_timeout: Explicit operation timeout for connection
+ to master node
+ :arg s: Comma-separated list of column names or column aliases
+ to sort by
+ :arg time: The unit in which to display time values Valid
+ choices: d (Days), h (Hours), m (Minutes), s (Seconds), ms
+ (Milliseconds), micros (Microseconds), nanos (Nanoseconds)
+ :arg v: Verbose mode. Display column headers
"""
- if repository in SKIP_IN_PATH:
- raise ValueError("Empty value passed for a required argument 'repository'.")
return self.transport.perform_request(
"GET", _make_path("_cat", "snapshots", repository), params=params
)
@@ -429,55 +483,58 @@ class CatClient(NamespacedClient):
"format",
"h",
"help",
- "nodes",
"node_id",
- "parent_task_id",
+ "parent_task",
"s",
+ "time",
"v",
)
def tasks(self, params=None):
"""
+ Returns information about the tasks currently executing on one or more nodes in
+ the cluster.
+ ``_
- ``_
-
- :arg actions: A comma-separated list of actions that should be returned.
- Leave empty to return all.
+ :arg actions: A comma-separated list of actions that should be
+ returned. Leave empty to return all.
:arg detailed: Return detailed task information (default: false)
- :arg format: a short version of the Accept header, e.g. json, yaml
+ :arg format: a short version of the Accept header, e.g. json,
+ yaml
:arg h: Comma-separated list of column names to display
- :arg help: Return help information, default False
- :arg nodes: 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 (used for older version of Elasticsearch)
- :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
+ :arg help: Return help information
+ :arg node_id: A comma-separated list of node IDs or names to
+ limit the returned information; use `_local` to return information from
+ the node you're connecting to, leave empty to get information from all
nodes
- :arg parent_task_id: Return tasks with specified parent task id. Set to -1
- to return all.
- :arg s: Comma-separated list of column names or column aliases to sort
- by
- :arg v: Verbose mode. Display column headers, default False
+ :arg parent_task: Return tasks with specified parent task id.
+ Set to -1 to return all.
+ :arg s: Comma-separated list of column names or column aliases
+ to sort by
+ :arg time: The unit in which to display time values Valid
+ choices: d (Days), h (Hours), m (Minutes), s (Seconds), ms
+ (Milliseconds), micros (Microseconds), nanos (Nanoseconds)
+ :arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request("GET", "/_cat/tasks", params=params)
@query_params("format", "h", "help", "local", "master_timeout", "s", "v")
def templates(self, name=None, params=None):
"""
- ``_
+ Returns information about existing templates.
+ ``_
:arg name: A pattern that returned template names must match
- :arg format: a short version of the Accept header, e.g. json, yaml
+ :arg format: a short version of the Accept header, e.g. json,
+ yaml
:arg h: Comma-separated list of column names to display
- :arg help: Return help information, default False
- :arg 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 s: Comma-separated list of column names or column aliases to sort
- by
- :arg v: Verbose mode. Display column headers, default False
+ :arg help: Return help information
+ :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 s: Comma-separated list of column names or column aliases
+ to sort by
+ :arg v: Verbose mode. Display column headers
"""
return self.transport.perform_request(
"GET", _make_path("_cat", "templates", name), params=params
diff --git a/elasticsearch/client/ccr.py b/elasticsearch/client/ccr.py
index 469e556f..9796eb5a 100644
--- a/elasticsearch/client/ccr.py
+++ b/elasticsearch/client/ccr.py
@@ -11,6 +11,7 @@ class CcrClient(NamespacedClient):
"""
if name in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'name'.")
+
return self.transport.perform_request(
"DELETE", _make_path("_ccr", "auto_follow", name), params=params
)
@@ -21,29 +22,33 @@ class CcrClient(NamespacedClient):
``_
:arg index: The name of the follower index
- :arg body: The name of the leader index and other optional ccr related
- parameters
- :arg wait_for_active_shards: Sets the number of shard copies that must
- be active before returning. Defaults to 0. Set to `all` for all
- shard copies, otherwise set to any non-negative value less than or
- equal to the total number of copies for the shard (number of
- replicas + 1), default '0'
+ :arg body: The name of the leader index and other optional ccr
+ related parameters
+ :arg wait_for_active_shards: Sets the number of shard copies
+ that must be active before returning. Defaults to 0. Set to `all` for
+ all shard copies, otherwise set to any non-negative value less than or
+ equal to the total number of copies for the shard (number of replicas +
+ 1) Default: 0
"""
for param in (index, body):
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")
+
return self.transport.perform_request(
"PUT", _make_path(index, "_ccr", "follow"), params=params, body=body
)
@query_params()
- def follow_info(self, index=None, params=None):
+ def follow_info(self, index, params=None):
"""
``_
- :arg index: A comma-separated list of index patterns; use `_all` to
- perform the operation on all indices
+ :arg index: A comma-separated list of index patterns; use `_all`
+ to perform the operation on all indices
"""
+ if index in SKIP_IN_PATH:
+ raise ValueError("Empty value passed for a required argument 'index'.")
+
return self.transport.perform_request(
"GET", _make_path(index, "_ccr", "info"), params=params
)
@@ -53,11 +58,12 @@ class CcrClient(NamespacedClient):
"""
``_
- :arg index: A comma-separated list of index patterns; use `_all` to
- perform the operation on all indices
+ :arg index: A comma-separated list of index patterns; use `_all`
+ to perform the operation on all indices
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'index'.")
+
return self.transport.perform_request(
"GET", _make_path(index, "_ccr", "stats"), params=params
)
@@ -67,16 +73,17 @@ class CcrClient(NamespacedClient):
"""
``_
- :arg index: the name of the leader index for which specified follower
- retention leases should be removed
- :arg body: the name and UUID of the follower index, the name of the
- cluster containing the follower index, and the alias from the
- perspective of that cluster for the remote cluster containing the
- leader index
+ :arg index: the name of the leader index for which specified
+ follower retention leases should be removed
+ :arg body: the name and UUID of the follower index, the name of
+ the cluster containing the follower index, and the alias from the
+ perspective of that cluster for the remote cluster containing the leader
+ index
"""
for param in (index, body):
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")
+
return self.transport.perform_request(
"POST",
_make_path(index, "_ccr", "forget_follower"),
@@ -100,11 +107,12 @@ class CcrClient(NamespacedClient):
"""
``_
- :arg index: The name of the follower index that should pause following
- its leader index.
+ :arg index: The name of the follower index that should pause
+ following its leader index.
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'index'.")
+
return self.transport.perform_request(
"POST", _make_path(index, "_ccr", "pause_follow"), params=params
)
@@ -120,6 +128,7 @@ class CcrClient(NamespacedClient):
for param in (name, body):
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")
+
return self.transport.perform_request(
"PUT", _make_path("_ccr", "auto_follow", name), params=params, body=body
)
@@ -130,11 +139,12 @@ class CcrClient(NamespacedClient):
``_
:arg index: The name of the follow index to resume following.
- :arg body: The name of the leader index and other optional ccr related
- parameters
+ :arg body: The name of the leader index and other optional ccr
+ related parameters
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'index'.")
+
return self.transport.perform_request(
"POST", _make_path(index, "_ccr", "resume_follow"), params=params, body=body
)
@@ -143,6 +153,7 @@ class CcrClient(NamespacedClient):
def stats(self, params=None):
"""
``_
+
"""
return self.transport.perform_request("GET", "/_ccr/stats", params=params)
@@ -151,11 +162,42 @@ class CcrClient(NamespacedClient):
"""
``_
- :arg index: The name of the follower index that should be turned into a
- regular index.
+ :arg index: The name of the follower index that should be turned
+ into a regular index.
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'index'.")
+
return self.transport.perform_request(
"POST", _make_path(index, "_ccr", "unfollow"), params=params
)
+
+ @query_params()
+ def pause_auto_follow_pattern(self, name, params=None):
+ """
+ ``_
+
+ :arg name: The name of the auto follow pattern that should pause
+ discovering new indices to follow.
+ """
+ if name in SKIP_IN_PATH:
+ raise ValueError("Empty value passed for a required argument 'name'.")
+
+ return self.transport.perform_request(
+ "POST", _make_path("_ccr", "auto_follow", name, "pause"), params=params
+ )
+
+ @query_params()
+ def resume_auto_follow_pattern(self, name, params=None):
+ """
+ ``_
+
+ :arg name: The name of the auto follow pattern to resume
+ discovering new indices to follow.
+ """
+ if name in SKIP_IN_PATH:
+ raise ValueError("Empty value passed for a required argument 'name'.")
+
+ return self.transport.perform_request(
+ "POST", _make_path("_ccr", "auto_follow", name, "resume"), params=params
+ )
diff --git a/elasticsearch/client/cluster.py b/elasticsearch/client/cluster.py
index cd186bae..1a869748 100644
--- a/elasticsearch/client/cluster.py
+++ b/elasticsearch/client/cluster.py
@@ -17,31 +17,33 @@ class ClusterClient(NamespacedClient):
)
def health(self, index=None, params=None):
"""
- Get a very simple status on the health of the cluster.
- ``_
+ Returns basic information about the health of the cluster.
+ ``_
:arg index: Limit the information returned to a specific index
- :arg expand_wildcards: Whether to expand wildcard expression to concrete
- indices that are open, closed or both., default 'all', valid choices
- are: 'open', 'closed', 'none', 'all'
- :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 expand_wildcards: Whether to expand wildcard expression to
+ concrete indices that are open, closed or both. Valid choices: open,
+ closed, none, all Default: all
+ :arg level: Specify the level of detail for returned information
+ Valid choices: cluster, indices, shards Default: 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 timeout: Explicit operation timeout
- :arg wait_for_active_shards: Wait until the specified number of shards
- is active
- :arg wait_for_events: Wait until all currently queued events with the
- given priority are processed, valid choices are: 'immediate',
- 'urgent', 'high', 'normal', 'low', 'languid'
- :arg wait_for_no_relocating_shards: Whether to wait until there are no
- relocating shards in the cluster
+ :arg wait_for_active_shards: Wait until the specified number of
+ shards is active
+ :arg wait_for_events: Wait until all currently queued events
+ with the given priority are processed Valid choices: immediate, urgent,
+ high, normal, low, languid
+ :arg wait_for_no_initializing_shards: Whether to wait until
+ there are no initializing shards in the cluster
+ :arg wait_for_no_relocating_shards: Whether to wait until there
+ are no relocating shards in the cluster
:arg wait_for_nodes: Wait until the specified number of nodes is
available
- :arg wait_for_status: Wait until cluster is in a specific state, default
- None, valid choices are: 'green', 'yellow', 'red'
+ :arg wait_for_status: Wait until cluster is in a specific state
+ Valid choices: green, yellow, red
"""
return self.transport.perform_request(
"GET", _make_path("_cluster", "health", index), params=params
@@ -50,13 +52,12 @@ class ClusterClient(NamespacedClient):
@query_params("local", "master_timeout")
def pending_tasks(self, params=None):
"""
- The pending cluster tasks API returns a list of any cluster-level
- changes (e.g. create index, update mapping, allocate or fail shard)
- which have not yet been executed.
- ``_
+ Returns a list of any cluster-level changes (e.g. create index, update mapping,
+ allocate or fail shard) 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
"""
return self.transport.perform_request(
@@ -75,31 +76,32 @@ class ClusterClient(NamespacedClient):
)
def state(self, metric=None, index=None, params=None):
"""
- Get a comprehensive state information of the whole cluster.
- ``_
+ Returns a comprehensive information about the state of the cluster.
+ ``_
- :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 metric: Limit the information returned to the specified
+ metrics Valid choices: _all, blocks, metadata, nodes, routing_table,
+ routing_nodes, master_node, version
+ :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 flat_settings: Return settings in flat format (default: false)
- :arg ignore_unavailable: Whether specified concrete indices should be
- ignored when unavailable (missing or closed)
- :arg local: Return local information, do not retrieve the state from
- master node (default: false)
+ :arg expand_wildcards: Whether to expand wildcard expression to
+ concrete indices that are open, closed or both. Valid choices: open,
+ closed, none, all Default: open
+ :arg flat_settings: Return settings in flat format (default:
+ false)
+ :arg ignore_unavailable: Whether specified concrete indices
+ should be ignored when unavailable (missing or closed)
+ :arg local: Return local information, do not retrieve the state
+ from master node (default: false)
:arg master_timeout: Specify timeout for connection to master
- :arg wait_for_metadata_version: Wait for the metadata version to be
- equal or greater than the specified metadata version
+ :arg wait_for_metadata_version: Wait for the metadata version to
+ be equal or greater than the specified metadata version
:arg wait_for_timeout: The maximum time to wait for
wait_for_metadata_version before timing out
"""
- if index and not metric:
- metric = "_all"
return self.transport.perform_request(
"GET", _make_path("_cluster", "state", metric, index), params=params
)
@@ -107,44 +109,42 @@ class ClusterClient(NamespacedClient):
@query_params("flat_settings", "timeout")
def stats(self, node_id=None, params=None):
"""
- The Cluster Stats API allows to retrieve statistics from a cluster wide
- perspective. The API returns basic index metrics and information about
- the current nodes that form the cluster.
- ``_
+ Returns high-level overview of cluster statistics.
+ ``_
- :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, `_master` to return information from the
- currently-elected master node or leave empty to get information from all
+ :arg node_id: A comma-separated list of node IDs or names to
+ limit the returned information; use `_local` to return information from
+ the node you're connecting to, leave empty to get information from all
nodes
- :arg flat_settings: Return settings in flat format (default: false)
+ :arg flat_settings: Return settings in flat format (default:
+ false)
:arg timeout: Explicit operation timeout
"""
- url = "/_cluster/stats"
- if node_id:
- url = _make_path("_cluster", "stats", "nodes", node_id)
- return self.transport.perform_request("GET", url, params=params)
+ return self.transport.perform_request(
+ "GET", _make_path("_cluster", "stats", "nodes", node_id), params=params
+ )
@query_params(
"dry_run", "explain", "master_timeout", "metric", "retry_failed", "timeout"
)
def reroute(self, body=None, params=None):
"""
- Explicitly execute a cluster reroute allocation command including specific commands.
- ``_
+ Allows to manually change the allocation of individual shards in the cluster.
+ ``_
- :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 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, valid choices are: '_all', 'blocks',
- 'metadata', 'nodes', 'routing_table', 'master_node', 'version'
- :arg retry_failed: Retries allocation of shards that are blocked due to
- too many subsequent allocation failures
+ :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 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 Valid choices: _all, blocks,
+ metadata, nodes, routing_table, master_node, version
+ :arg retry_failed: Retries allocation of shards that are blocked
+ due to too many subsequent allocation failures
:arg timeout: Explicit operation timeout
"""
return self.transport.perform_request(
@@ -154,14 +154,15 @@ class ClusterClient(NamespacedClient):
@query_params("flat_settings", "include_defaults", "master_timeout", "timeout")
def get_settings(self, params=None):
"""
- Get cluster settings.
- ``_
+ Returns cluster settings.
+ ``_
- :arg flat_settings: Return settings in flat format (default: false)
- :arg include_defaults: Whether to return all default clusters setting.,
- default False
- :arg master_timeout: Explicit operation timeout for connection to master
- node
+ :arg flat_settings: Return settings in flat format (default:
+ false)
+ :arg include_defaults: Whether to return all default clusters
+ setting.
+ :arg master_timeout: Explicit operation timeout for connection
+ to master node
:arg timeout: Explicit operation timeout
"""
return self.transport.perform_request(
@@ -169,18 +170,22 @@ class ClusterClient(NamespacedClient):
)
@query_params("flat_settings", "master_timeout", "timeout")
- def put_settings(self, body=None, params=None):
+ def put_settings(self, body, params=None):
"""
- Update cluster wide specific settings.
- ``_
+ Updates the cluster settings.
+ ``_
- :arg body: The settings to be updated. Can be either `transient` or
- `persistent` (survives cluster restart).
- :arg flat_settings: Return settings in flat format (default: false)
- :arg master_timeout: Explicit operation timeout for connection to master
- node
+ :arg body: The settings to be updated. Can be either `transient`
+ or `persistent` (survives cluster restart).
+ :arg flat_settings: Return settings in flat format (default:
+ false)
+ :arg master_timeout: Explicit operation timeout for connection
+ to master node
:arg timeout: Explicit operation timeout
"""
+ if body in SKIP_IN_PATH:
+ raise ValueError("Empty value passed for a required argument 'body'.")
+
return self.transport.perform_request(
"PUT", "/_cluster/settings", params=params, body=body
)
@@ -188,21 +193,24 @@ class ClusterClient(NamespacedClient):
@query_params()
def remote_info(self, params=None):
"""
- ``_
+ Returns the information about configured remote clusters.
+ ``_
+
"""
return self.transport.perform_request("GET", "/_remote/info", params=params)
@query_params("include_disk_info", "include_yes_decisions")
def allocation_explain(self, body=None, params=None):
"""
- ``_
+ Provides explanations for shard allocations in the cluster.
+ ``_
- :arg body: The index, shard, and primary flag to explain. Empty means
- 'explain the first unassigned shard'
- :arg include_disk_info: Return information about disk usage and shard
- sizes (default: false)
- :arg include_yes_decisions: Return 'YES' decisions in explanation
- (default: false)
+ :arg body: The index, shard, and primary flag to explain. Empty
+ means 'explain the first unassigned shard'
+ :arg include_disk_info: Return information about disk usage and
+ shard sizes (default: false)
+ :arg include_yes_decisions: Return 'YES' decisions in
+ explanation (default: false)
"""
return self.transport.perform_request(
"GET", "/_cluster/allocation/explain", params=params, body=body
diff --git a/elasticsearch/client/enrich.py b/elasticsearch/client/enrich.py
new file mode 100644
index 00000000..d2952437
--- /dev/null
+++ b/elasticsearch/client/enrich.py
@@ -0,0 +1,68 @@
+from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
+
+
+class EnrichClient(NamespacedClient):
+ @query_params()
+ def delete_policy(self, name, params=None):
+ """
+ ``_
+
+ :arg name: The name of the enrich policy
+ """
+ if name in SKIP_IN_PATH:
+ raise ValueError("Empty value passed for a required argument 'name'.")
+
+ return self.transport.perform_request(
+ "DELETE", _make_path("_enrich", "policy", name), params=params
+ )
+
+ @query_params("wait_for_completion")
+ def execute_policy(self, name, params=None):
+ """
+ ``_
+
+ :arg name: The name of the enrich policy
+ :arg wait_for_completion: Should the request should block until
+ the execution is complete. Default: True
+ """
+ if name in SKIP_IN_PATH:
+ raise ValueError("Empty value passed for a required argument 'name'.")
+
+ return self.transport.perform_request(
+ "PUT", _make_path("_enrich", "policy", name, "_execute"), params=params
+ )
+
+ @query_params()
+ def get_policy(self, name=None, params=None):
+ """
+ ``_
+
+ :arg name: The name of the enrich policy
+ """
+ return self.transport.perform_request(
+ "GET", _make_path("_enrich", "policy", name), params=params
+ )
+
+ @query_params()
+ def put_policy(self, name, body, params=None):
+ """
+ ``_
+
+ :arg name: The name of the enrich policy
+ :arg body: The enrich policy to register
+ """
+ for param in (name, body):
+ if param in SKIP_IN_PATH:
+ raise ValueError("Empty value passed for a required argument.")
+
+ return self.transport.perform_request(
+ "PUT", _make_path("_enrich", "policy", name), params=params, body=body
+ )
+
+ @query_params()
+ def stats(self, params=None):
+ """
+ ``_
+
+ """
+ return self.transport.perform_request("GET", "/_enrich/_stats", params=params)
diff --git a/elasticsearch/client/graph.py b/elasticsearch/client/graph.py
index 2d438b5e..cf8f57b0 100644
--- a/elasticsearch/client/graph.py
+++ b/elasticsearch/client/graph.py
@@ -3,18 +3,21 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
class GraphClient(NamespacedClient):
@query_params("routing", "timeout")
- def explore(self, index=None, doc_type=None, body=None, params=None):
+ def explore(self, index, body=None, doc_type=None, params=None):
"""
``_
- :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 index: A comma-separated list of index names to search; use
+ `_all` or empty string to perform the operation on all indices
:arg body: Graph Query DSL
+ :arg doc_type: A comma-separated list of document types to
+ search; leave empty to perform the operation on all types
:arg routing: Specific routing value
:arg timeout: Explicit operation timeout
"""
+ if index in SKIP_IN_PATH:
+ raise ValueError("Empty value passed for a required argument 'index'.")
+
return self.transport.perform_request(
"GET",
_make_path(index, doc_type, "_graph", "explore"),
diff --git a/elasticsearch/client/ilm.py b/elasticsearch/client/ilm.py
index 6b3938bc..142a343c 100644
--- a/elasticsearch/client/ilm.py
+++ b/elasticsearch/client/ilm.py
@@ -3,23 +3,33 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
class IlmClient(NamespacedClient):
@query_params()
- def delete_lifecycle(self, policy=None, params=None):
+ def delete_lifecycle(self, policy, params=None):
"""
``_
:arg policy: The name of the index lifecycle policy
"""
+ if policy in SKIP_IN_PATH:
+ raise ValueError("Empty value passed for a required argument 'policy'.")
+
return self.transport.perform_request(
"DELETE", _make_path("_ilm", "policy", policy), params=params
)
- @query_params()
- def explain_lifecycle(self, index=None, params=None):
+ @query_params("only_errors", "only_managed")
+ def explain_lifecycle(self, index, params=None):
"""
``_
:arg index: The name of the index to explain
+ :arg only_errors: filters the indices included in the response
+ to ones in an ILM error state, implies only_managed
+ :arg only_managed: filters the indices included in the response
+ to ones managed by ILM
"""
+ if index in SKIP_IN_PATH:
+ raise ValueError("Empty value passed for a required argument 'index'.")
+
return self.transport.perform_request(
"GET", _make_path(index, "_ilm", "explain"), params=params
)
@@ -39,52 +49,66 @@ class IlmClient(NamespacedClient):
def get_status(self, params=None):
"""
``_
+
"""
return self.transport.perform_request("GET", "/_ilm/status", params=params)
@query_params()
- def move_to_step(self, index=None, body=None, params=None):
+ def move_to_step(self, index, body=None, params=None):
"""
``_
- :arg index: The name of the index whose lifecycle step is to change
+ :arg index: The name of the index whose lifecycle step is to
+ change
:arg body: The new lifecycle step to move to
"""
+ if index in SKIP_IN_PATH:
+ raise ValueError("Empty value passed for a required argument 'index'.")
+
return self.transport.perform_request(
"POST", _make_path("_ilm", "move", index), params=params, body=body
)
@query_params()
- def put_lifecycle(self, policy=None, body=None, params=None):
+ def put_lifecycle(self, policy, body=None, params=None):
"""
``_
:arg policy: The name of the index lifecycle policy
:arg body: The lifecycle policy definition to register
"""
+ if policy in SKIP_IN_PATH:
+ raise ValueError("Empty value passed for a required argument 'policy'.")
+
return self.transport.perform_request(
"PUT", _make_path("_ilm", "policy", policy), params=params, body=body
)
@query_params()
- def remove_policy(self, index=None, params=None):
+ def remove_policy(self, index, params=None):
"""
``_
:arg index: The name of the index to remove policy on
"""
+ if index in SKIP_IN_PATH:
+ raise ValueError("Empty value passed for a required argument 'index'.")
+
return self.transport.perform_request(
"POST", _make_path(index, "_ilm", "remove"), params=params
)
@query_params()
- def retry(self, index=None, params=None):
+ def retry(self, index, params=None):
"""
``_
- :arg index: The name of the indices (comma-separated) whose failed
- lifecycle step is to be retry
+ :arg index: The name of the indices (comma-separated) whose
+ failed lifecycle step is to be retry
"""
+ if index in SKIP_IN_PATH:
+ raise ValueError("Empty value passed for a required argument 'index'.")
+
return self.transport.perform_request(
"POST", _make_path(index, "_ilm", "retry"), params=params
)
@@ -93,6 +117,7 @@ class IlmClient(NamespacedClient):
def start(self, params=None):
"""
``_
+
"""
return self.transport.perform_request("POST", "/_ilm/start", params=params)
@@ -100,5 +125,6 @@ class IlmClient(NamespacedClient):
def stop(self, params=None):
"""
``_
+
"""
return self.transport.perform_request("POST", "/_ilm/stop", params=params)
diff --git a/elasticsearch/client/indices.py b/elasticsearch/client/indices.py
index cee065db..073f2b7f 100644
--- a/elasticsearch/client/indices.py
+++ b/elasticsearch/client/indices.py
@@ -2,19 +2,17 @@ from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH
class IndicesClient(NamespacedClient):
- @query_params("format", "prefer_local")
- def analyze(self, index=None, body=None, params=None):
+ @query_params("index")
+ def analyze(self, body=None, index=None, params=None):
"""
- Perform the analysis process on a text and return the tokens breakdown of the text.
- ``_
+ Performs the analysis process on a text and return the tokens breakdown of the
+ text.
+ ``_
+ :arg body: Define analyzer/tokenizer parameters and the text on
+ which the analysis should be performed
+ :arg index: The name of the index to scope the operation
:arg index: The name of the index to scope the operation
- :arg body: Define analyzer/tokenizer parameters and the text on which
- the analysis should be performed
- :arg format: Format of the output, default 'detailed', valid choices
- are: 'detailed', 'text'
- :arg prefer_local: With `true`, specify that a local shard should be
- used if available, with `false`, use a random shard (default: true)
"""
return self.transport.perform_request(
"GET", _make_path(index, "_analyze"), params=params, body=body
@@ -23,20 +21,19 @@ class IndicesClient(NamespacedClient):
@query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable")
def refresh(self, index=None, params=None):
"""
- Explicitly refresh one or more index, making all operations performed
- since the last refresh available for search.
- ``_
+ Performs the refresh operation in one or more indices.
+ ``_
- :arg index: A comma-separated list of index names; use `_all` or empty
- string to perform the operation on all indices
+ :arg 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 expand_wildcards: Whether to expand wildcard expression to
+ concrete indices that are open, closed or both. Valid choices: open,
+ closed, none, all Default: open
+ :arg ignore_unavailable: Whether specified concrete indices
+ should be ignored when unavailable (missing or closed)
"""
return self.transport.perform_request(
"POST", _make_path(index, "_refresh"), params=params
@@ -51,52 +48,54 @@ class IndicesClient(NamespacedClient):
)
def flush(self, index=None, params=None):
"""
- Explicitly flush one or more indices.
- ``_
+ Performs the flush operation on one or more indices.
+ ``_
- :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; 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 expand_wildcards: Whether to expand wildcard expression to
+ concrete indices that are open, closed or both. Valid choices: open,
+ closed, none, all Default: open
: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.
- 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 true. If set to false the flush
- will be skipped iff if another flush operation is already running.
+ 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 true. If set to false the flush will
+ be skipped iff if another flush operation is already running.
"""
return self.transport.perform_request(
"POST", _make_path(index, "_flush"), params=params
)
@query_params(
- "master_timeout", "timeout", "wait_for_active_shards", "include_type_name",
+ "include_type_name", "master_timeout", "timeout", "wait_for_active_shards"
)
def create(self, index, body=None, params=None):
"""
- Create an index in Elasticsearch.
- ``_
+ Creates an index with optional settings and mappings.
+ ``_
:arg index: The name of the index
- :arg body: The configuration for the index (`settings` and `mappings`)
+ :arg body: The configuration for the index (`settings` and
+ `mappings`)
+ :arg include_type_name: Whether a type should be expected in the
+ body of the mappings.
:arg master_timeout: Specify timeout for connection to master
:arg timeout: Explicit operation timeout
- :arg wait_for_active_shards: Set the number of active shards to wait for
- before the operation returns.
- :arg include_type_name: Specify whether requests and responses should include a
- type name (default: depends on Elasticsearch version).
+ :arg wait_for_active_shards: Set the number of active shards to
+ wait for before the operation returns.
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'index'.")
+
return self.transport.perform_request(
"PUT", _make_path(index), params=params, body=body
)
@@ -105,19 +104,20 @@ class IndicesClient(NamespacedClient):
def clone(self, index, target, body=None, params=None):
"""
Clones an index
- ``_
+ ``_
:arg index: The name of the source index to clone
:arg target: The name of the target index to clone into
+ :arg body: The configuration for the target index (`settings`
+ and `aliases`)
:arg master_timeout: Specify timeout for connection to master
:arg timeout: Explicit operation timeout
- :arg wait_for_active_shards: Set the number of active shards to wait for
- before the operation returns.
+ :arg wait_for_active_shards: Set the number of active shards to
+ wait for on the cloned index before the operation returns.
"""
- if index in SKIP_IN_PATH:
- raise ValueError("Empty value passed for a required argument 'index'.")
- if target in SKIP_IN_PATH:
- raise ValueError("Empty value passed for a required argument 'target'.")
+ for param in (index, target):
+ if param in SKIP_IN_PATH:
+ raise ValueError("Empty value passed for a required argument.")
return self.transport.perform_request(
"PUT", _make_path(index, "_clone", target), params=params, body=body
@@ -129,36 +129,37 @@ class IndicesClient(NamespacedClient):
"flat_settings",
"ignore_unavailable",
"include_defaults",
- "local",
"include_type_name",
+ "local",
"master_timeout",
)
- def get(self, index, feature=None, params=None):
+ def get(self, index, params=None):
"""
- The get index API allows to retrieve information about one or more indexes.
- ``_
+ Returns information about one or more indices.
+ ``_
:arg index: A comma-separated list of index names
- :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), default 'open', valid
- choices are: 'open', 'closed', 'none', 'all'
- :arg flat_settings: Return settings in flat format (default: false)
- :arg ignore_unavailable: Ignore unavailable indexes (default: false)
- :arg include_defaults: Whether to return all default setting for each of
- the indices., default False
- :arg local: Return local information, do not retrieve the state from
- master node (default: false)
- :arg include_type_name: Specify whether requests and responses should include a
- type name (default: depends on Elasticsearch version).
+ :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) Valid choices: open,
+ closed, none, all Default: open
+ :arg flat_settings: Return settings in flat format (default:
+ false)
+ :arg ignore_unavailable: Ignore unavailable indexes (default:
+ false)
+ :arg include_defaults: Whether to return all default setting for
+ each of the indices.
+ :arg include_type_name: Whether to add the type name to the
+ response (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
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'index'.")
- return self.transport.perform_request(
- "GET", _make_path(index, feature), params=params
- )
+
+ return self.transport.perform_request("GET", _make_path(index), params=params)
@query_params(
"allow_no_indices",
@@ -170,25 +171,26 @@ class IndicesClient(NamespacedClient):
)
def open(self, index, params=None):
"""
- Open a closed index to make it available for search.
- ``_
+ Opens an index.
+ ``_
- :arg index: The name of the index
+ :arg index: A comma separated list of indices to open
: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 expand_wildcards: Whether to expand wildcard expression to
+ concrete indices that are open, closed or both. Valid choices: open,
+ closed, none, all Default: closed
+ :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 wait_for_active_shards: Sets the number of active shards to wait
- for before the operation returns.
+ :arg wait_for_active_shards: Sets the number of active shards to
+ wait for before the operation returns.
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'index'.")
+
return self.transport.perform_request(
"POST", _make_path(index, "_open"), params=params
)
@@ -198,29 +200,31 @@ class IndicesClient(NamespacedClient):
"expand_wildcards",
"ignore_unavailable",
"master_timeout",
+ "timeout",
"wait_for_active_shards",
)
def close(self, index, params=None):
"""
- Close an index to remove it's overhead from the cluster. Closed index
- is blocked for read/write operations.
- ``_
+ Closes an index.
+ ``_
- :arg index: The name of the index
+ :arg index: A comma separated list of indices to close
: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 expand_wildcards: Whether to expand wildcard expression to
+ concrete indices that are open, closed or both. Valid choices: open,
+ closed, none, all Default: open
+ :arg ignore_unavailable: Whether specified concrete indices
+ should be ignored when unavailable (missing or closed)
:arg master_timeout: Specify timeout for connection to master
- :arg wait_for_active_shards: Sets the number of active shards to wait
- for before the operation returns.
+ :arg timeout: Explicit operation timeout
+ :arg wait_for_active_shards: Sets the number of active shards to
+ wait for before the operation returns.
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'index'.")
+
return self.transport.perform_request(
"POST", _make_path(index, "_close"), params=params
)
@@ -229,27 +233,29 @@ class IndicesClient(NamespacedClient):
"allow_no_indices",
"expand_wildcards",
"ignore_unavailable",
- "timeout",
"master_timeout",
+ "timeout",
)
def delete(self, index, params=None):
"""
- Delete an index in Elasticsearch
- ``_
+ Deletes an index.
+ ``_
- :arg index: A comma-separated list of indices to delete; use `_all` or
- `*` string to delete all indices
- :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), default 'open', valid
- choices are: 'open', 'closed', 'none', 'all'
- :arg ignore_unavailable: Ignore unavailable indexes (default: false)
+ :arg index: A comma-separated list of indices to delete; use
+ `_all` or `*` string to delete all indices
+ :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) Valid choices: open,
+ closed, none, all Default: open
+ :arg ignore_unavailable: Ignore unavailable indexes (default:
+ false)
:arg master_timeout: Specify timeout for connection to master
:arg timeout: Explicit operation timeout
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'index'.")
+
return self.transport.perform_request(
"DELETE", _make_path(index), params=params
)
@@ -264,49 +270,54 @@ class IndicesClient(NamespacedClient):
)
def exists(self, index, params=None):
"""
- Return a boolean indicating whether given index exists.
- ``_
+ Returns information about whether a particular index exists.
+ ``_
:arg index: A comma-separated list of index names
- :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), default 'open', valid
- choices are: 'open', 'closed', 'none', 'all'
- :arg flat_settings: Return settings in flat format (default: false)
- :arg ignore_unavailable: Ignore unavailable indexes (default: false)
- :arg include_defaults: Whether to return all default setting for each of
- the indices., default False
- :arg local: Return local information, do not retrieve the state from
- master node (default: false)
+ :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) Valid choices: open,
+ closed, none, all Default: open
+ :arg flat_settings: Return settings in flat format (default:
+ false)
+ :arg ignore_unavailable: Ignore unavailable indexes (default:
+ false)
+ :arg include_defaults: Whether to return all default setting for
+ each of the indices.
+ :arg local: Return local information, do not retrieve the state
+ from master node (default: false)
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'index'.")
+
return self.transport.perform_request("HEAD", _make_path(index), params=params)
@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.
- ``_
+ Returns information about whether a particular document type exists.
+ (DEPRECATED)
+ ``_
- :arg index: A comma-separated list of index names; use `_all` to check
- the types across all indices
+ :arg index: A comma-separated list of index names; use `_all` to
+ check 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., 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)
+ :arg expand_wildcards: Whether to expand wildcard expression to
+ concrete indices that are open, closed or both. Valid choices: open,
+ closed, none, all Default: open
+ :arg ignore_unavailable: Whether specified concrete indices
+ should be ignored when unavailable (missing or closed)
+ :arg local: Return local information, do not retrieve the state
+ from master node (default: false)
"""
for param in (index, doc_type):
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")
+
return self.transport.perform_request(
"HEAD", _make_path(index, "_mapping", doc_type), params=params
)
@@ -315,67 +326,67 @@ class IndicesClient(NamespacedClient):
"allow_no_indices",
"expand_wildcards",
"ignore_unavailable",
+ "include_type_name",
"master_timeout",
"timeout",
- "include_type_name",
)
- def put_mapping(self, body, doc_type=None, index=None, params=None):
+ def put_mapping(self, body, index=None, doc_type=None, params=None):
"""
- Register specific mapping definition for a specific type.
- ``_
+ Updates the index mappings.
+ ``_
:arg body: The mapping definition
+ :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 doc_type: The name of the document type
- :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 'open', valid
- choices are: 'open', 'closed', 'none', 'all'
- :arg ignore_unavailable: Whether specified concrete indices should be
- ignored when unavailable (missing or closed)
+ :arg expand_wildcards: Whether to expand wildcard expression to
+ concrete indices that are open, closed or both. Valid choices: open,
+ closed, none, all Default: open
+ :arg ignore_unavailable: Whether specified concrete indices
+ should be ignored when unavailable (missing or closed)
+ :arg include_type_name: Whether a type should be expected in the
+ body of the mappings.
:arg master_timeout: Specify timeout for connection to master
:arg timeout: Explicit operation timeout
- :arg include_type_name: Specify whether requests and responses should include a
- type name (default: depends on Elasticsearch version).
"""
- for param in (body,):
- if param in SKIP_IN_PATH:
- raise ValueError("Empty value passed for a required argument.")
+ if body in SKIP_IN_PATH:
+ raise ValueError("Empty value passed for a required argument 'body'.")
+
return self.transport.perform_request(
- "PUT", _make_path(index, "_mapping", doc_type), params=params, body=body
+ "PUT", _make_path(index, doc_type, "_mapping"), params=params, body=body
)
@query_params(
"allow_no_indices",
"expand_wildcards",
"ignore_unavailable",
- "local",
"include_type_name",
+ "local",
"master_timeout",
)
def get_mapping(self, index=None, doc_type=None, params=None):
"""
- Retrieve mapping definition of index or index/type.
- ``_
+ Returns mappings for one or more 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., 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)
- :arg include_type_name: Specify whether requests and responses should include a
- type name (default: depends on Elasticsearch version).
+ :arg expand_wildcards: Whether to expand wildcard expression to
+ concrete indices that are open, closed or both. Valid choices: open,
+ closed, none, all Default: open
+ :arg ignore_unavailable: Whether specified concrete indices
+ should be ignored when unavailable (missing or closed)
+ :arg include_type_name: Whether to add the type name to the
+ response (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
"""
return self.transport.perform_request(
@@ -387,13 +398,13 @@ class IndicesClient(NamespacedClient):
"expand_wildcards",
"ignore_unavailable",
"include_defaults",
- "local",
"include_type_name",
+ "local",
)
def get_field_mapping(self, fields, index=None, doc_type=None, params=None):
"""
- Retrieve mapping definition of a specific field.
- ``_
+ Returns mapping for one or more fields.
+ ``_
:arg fields: A comma-separated list of fields
:arg index: A comma-separated list of index names
@@ -401,65 +412,73 @@ class IndicesClient(NamespacedClient):
: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 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)
- :arg include_type_name: Specify whether requests and responses should include a
- type name (default: depends on Elasticsearch version).
+ :arg expand_wildcards: Whether to expand wildcard expression to
+ concrete indices that are open, closed or both. Valid choices: open,
+ closed, none, all Default: open
+ :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 include_type_name: Whether a type should be returned in the
+ body of the mappings.
+ :arg local: Return local information, do not retrieve the state
+ from master node (default: false)
"""
if fields in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'fields'.")
+
return self.transport.perform_request(
"GET",
_make_path(index, "_mapping", doc_type, "field", fields),
params=params,
)
- @query_params("master_timeout")
+ @query_params("master_timeout", "timeout")
def put_alias(self, index, name, body=None, params=None):
"""
- Create an alias for a specific index/indices.
- ``_
+ Creates or updates an alias.
+ ``_
- :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 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 body: The settings for the alias, such as `routing` or
+ `filter`
: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.")
+
return self.transport.perform_request(
"PUT", _make_path(index, "_alias", name), params=params, body=body
)
@query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable", "local")
- def exists_alias(self, index=None, name=None, params=None):
+ def exists_alias(self, name, index=None, params=None):
"""
- Return a boolean indicating whether given alias exists.
- ``_
+ Returns information about whether a particular alias exists.
+ ``_
- :arg index: A comma-separated list of index names to filter aliases
:arg name: A comma-separated list of alias names to return
+ :arg index: A comma-separated list of index names to filter
+ aliases
: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 'all', 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)
+ :arg expand_wildcards: Whether to expand wildcard expression to
+ concrete indices that are open, closed or both. Valid choices: open,
+ closed, none, all Default: 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)
"""
+ if name in SKIP_IN_PATH:
+ raise ValueError("Empty value passed for a required argument 'name'.")
+
return self.transport.perform_request(
"HEAD", _make_path(index, "_alias", name), params=params
)
@@ -467,21 +486,22 @@ class IndicesClient(NamespacedClient):
@query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable", "local")
def get_alias(self, index=None, name=None, params=None):
"""
- Retrieve a specified alias.
- ``_
+ Returns an alias.
+ ``_
- :arg index: A comma-separated list of index names to filter aliases
+ :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., default 'all', 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)
+ :arg expand_wildcards: Whether to expand wildcard expression to
+ concrete indices that are open, closed or both. Valid choices: open,
+ closed, none, all Default: 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)
"""
return self.transport.perform_request(
"GET", _make_path(index, "_alias", name), params=params
@@ -490,8 +510,8 @@ class IndicesClient(NamespacedClient):
@query_params("master_timeout", "timeout")
def update_aliases(self, body, params=None):
"""
- Update specified aliases.
- ``_
+ Updates index aliases.
+ ``_
:arg body: The definition of `actions` to perform
:arg master_timeout: Specify timeout for connection to master
@@ -499,6 +519,7 @@ class IndicesClient(NamespacedClient):
"""
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")
+
return self.transport.perform_request(
"POST", "/_aliases", params=params, body=body
)
@@ -506,20 +527,20 @@ class IndicesClient(NamespacedClient):
@query_params("master_timeout", "timeout")
def delete_alias(self, index, name, params=None):
"""
- Delete specific alias.
- ``_
+ Deletes an alias.
+ ``_
- :arg index: A comma-separated list of index names (supports wildcards);
- use `_all` for all indices
+ :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 timeout for the operation
+ :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.")
+
return self.transport.perform_request(
"DELETE", _make_path(index, "_alias", name), params=params
)
@@ -527,32 +548,34 @@ class IndicesClient(NamespacedClient):
@query_params(
"create",
"flat_settings",
+ "include_type_name",
"master_timeout",
"order",
"timeout",
- "include_type_name",
)
def put_template(self, name, body, params=None):
"""
- Create an index template that will automatically be applied to new
- indices created.
- ``_
+ Creates or updates an index template.
+ ``_
: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, default False
- :arg flat_settings: Return settings in flat format (default: false)
+ :arg create: Whether the index template should only be added if
+ new or can also replace an existing one
+ :arg flat_settings: Return settings in flat format (default:
+ false)
+ :arg include_type_name: Whether a type should be returned in the
+ body of the mappings.
: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 order: The order for this template when merging multiple
+ matching ones (higher numbers are merged later, overriding the lower
+ numbers)
:arg timeout: Explicit operation timeout
- :arg include_type_name: Specify whether requests and responses should include a
- type name (default: depends on Elasticsearch version).
"""
for param in (name, body):
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")
+
return self.transport.perform_request(
"PUT", _make_path("_template", name), params=params, body=body
)
@@ -560,36 +583,39 @@ class IndicesClient(NamespacedClient):
@query_params("flat_settings", "local", "master_timeout")
def exists_template(self, name, params=None):
"""
- Return a boolean indicating whether given template exists.
- ``_
+ Returns information about whether a particular index template exists.
+ ``_
:arg name: The comma separated names of the index templates
- :arg flat_settings: Return settings in flat format (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 flat_settings: Return settings in flat format (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
"""
if name in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'name'.")
+
return self.transport.perform_request(
"HEAD", _make_path("_template", name), params=params
)
- @query_params("flat_settings", "local", "master_timeout", "include_type_name")
+ @query_params("flat_settings", "include_type_name", "local", "master_timeout")
def get_template(self, name=None, params=None):
"""
- Retrieve an index template by its name.
- ``_
+ Returns an index template.
+ ``_
- :arg name: The name of the template
- :arg flat_settings: Return settings in flat format (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 include_type_name: Specify whether requests and responses should include a
- type name (default: depends on Elasticsearch version).
+ :arg name: The comma separated names of the index templates
+ :arg flat_settings: Return settings in flat format (default:
+ false)
+ :arg include_type_name: Whether a type should be returned in the
+ body of the mappings.
+ :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
"""
return self.transport.perform_request(
"GET", _make_path("_template", name), params=params
@@ -598,8 +624,8 @@ class IndicesClient(NamespacedClient):
@query_params("master_timeout", "timeout")
def delete_template(self, name, params=None):
"""
- Delete an index template by its name.
- ``_
+ Deletes an index template.
+ ``_
:arg name: The name of the template
:arg master_timeout: Specify timeout for connection to master
@@ -607,6 +633,7 @@ class IndicesClient(NamespacedClient):
"""
if name in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'name'.")
+
return self.transport.perform_request(
"DELETE", _make_path("_template", name), params=params
)
@@ -622,25 +649,26 @@ class IndicesClient(NamespacedClient):
)
def get_settings(self, index=None, name=None, params=None):
"""
- Retrieve settings for one or more (or all) indices.
- ``_
+ Returns settings for one or more indices.
+ ``_
- :arg index: A comma-separated list of index names; use `_all` or empty
- string to perform the operation on all indices
+ :arg 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 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 ignore_unavailable: Whether specified concrete indices should be
- ignored when unavailable (missing or closed)
- :arg include_defaults: Whether to return all default setting for each of
- the indices., default False
- :arg local: Return local information, do not retrieve the state from
- master node (default: false)
+ :arg expand_wildcards: Whether to expand wildcard expression to
+ concrete indices that are open, closed or both. Valid choices: open,
+ closed, none, all Default: ['open', 'closed']
+ :arg flat_settings: Return settings in flat format (default:
+ false)
+ :arg ignore_unavailable: Whether specified concrete indices
+ should be ignored when unavailable (missing or closed)
+ :arg include_defaults: Whether to return all default setting for
+ each of the indices.
+ :arg local: Return local information, do not retrieve the state
+ from master node (default: false)
:arg master_timeout: Specify timeout for connection to master
"""
return self.transport.perform_request(
@@ -653,34 +681,36 @@ class IndicesClient(NamespacedClient):
"flat_settings",
"ignore_unavailable",
"master_timeout",
- "timeout",
"preserve_existing",
+ "timeout",
)
def put_settings(self, body, index=None, params=None):
"""
- Change specific index level settings in real time.
- ``_
+ Updates the index settings.
+ ``_
:arg body: The index settings to be updated
- :arg index: A comma-separated list of index names; use `_all` or empty
- string to perform the operation on all indices
+ :arg 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 flat_settings: Return settings in flat format (default: false)
- :arg ignore_unavailable: Whether specified concrete indices should be
- ignored when unavailable (missing or closed)
+ :arg expand_wildcards: Whether to expand wildcard expression to
+ concrete indices that are open, closed or both. Valid choices: open,
+ closed, none, all Default: open
+ :arg flat_settings: Return settings in flat format (default:
+ false)
+ :arg ignore_unavailable: Whether specified concrete indices
+ should be ignored when unavailable (missing or closed)
:arg master_timeout: Specify timeout for connection to master
- :arg preserve_existing: Whether to update existing settings. If set to
- `true` existing settings on an index remain unchanged, the default
- is `false`
+ :arg preserve_existing: Whether to update existing settings. If
+ set to `true` existing settings on an index remain unchanged, the
+ default is `false`
:arg timeout: Explicit operation timeout
"""
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")
+
return self.transport.perform_request(
"PUT", _make_path(index, "_settings"), params=params, body=body
)
@@ -699,65 +729,63 @@ class IndicesClient(NamespacedClient):
)
def stats(self, index=None, metric=None, params=None):
"""
- Retrieve statistics on different operations happening on an index.
- ``_
+ Provides statistics on operations happening in an index.
+ ``_
- :arg index: A comma-separated list of index names; use `_all` or empty
- string to perform the operation on all indices
- :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 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 fielddata_fields: A comma-separated list of fields for `fielddata`
- index metric (supports wildcards)
- :arg fields: A comma-separated list of fields for `fielddata` and
- `completion` index metric (supports wildcards)
- :arg forbid_closed_indices: If set to false stats will also collected
- from closed indices if explicitly specified or if expand_wildcards
- expands to closed indices, default True
- :arg groups: A comma-separated list of search groups for `search` index
- metric
- :arg include_segment_file_sizes: Whether to report the aggregated disk
- usage of each one of the Lucene index files (only applies if segment
- stats are requested), default False
- :arg include_unloaded_segments: If set to true segment stats will
- include stats for segments that are not currently loaded into
- memory, 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
+ :arg index: A comma-separated list of index names; use `_all` or
+ empty string to perform the operation on all indices
+ :arg metric: Limit the information returned the specific
+ metrics. Valid choices: _all, completion, docs, fielddata, query_cache,
+ flush, get, indexing, merge, request_cache, refresh, search, segments,
+ store, warmer, suggest
+ :arg completion_fields: A comma-separated list of fields for
+ `fielddata` and `suggest` index metric (supports wildcards)
+ :arg expand_wildcards: Whether to expand wildcard expression to
+ concrete indices that are open, closed or both. Valid choices: open,
+ closed, none, all Default: open
+ :arg fielddata_fields: A comma-separated list of fields for
+ `fielddata` index metric (supports wildcards)
+ :arg fields: A comma-separated list of fields for `fielddata`
+ and `completion` index metric (supports wildcards)
+ :arg forbid_closed_indices: If set to false stats will also
+ collected from closed indices if explicitly specified or if
+ expand_wildcards expands to closed indices Default: True
+ :arg groups: A comma-separated list of search groups for
+ `search` index metric
+ :arg include_segment_file_sizes: Whether to report the
+ aggregated disk usage of each one of the Lucene index files (only
+ applies if segment stats are requested)
+ :arg include_unloaded_segments: If set to true segment stats
+ will include stats for segments that are not currently loaded into
+ memory
+ :arg level: Return stats aggregated at cluster, index or shard
+ level Valid choices: cluster, indices, shards Default: indices
+ :arg types: A comma-separated list of document types for the
+ `indexing` index metric
"""
return self.transport.perform_request(
"GET", _make_path(index, "_stats", metric), params=params
)
@query_params(
- "allow_no_indices",
- "expand_wildcards",
- "ignore_unavailable",
- "operation_threading",
- "verbose",
+ "allow_no_indices", "expand_wildcards", "ignore_unavailable", "verbose"
)
def segments(self, index=None, params=None):
"""
- Provide low level segments information that a Lucene index (shard level) is built with.
- ``_
+ Provides low-level information about segments in a Lucene index.
+ ``_
- :arg index: A comma-separated list of index names; use `_all` or empty
- string to perform the operation on all indices
+ :arg index: A comma-separated list of index names; use `_all` or
+ empty string to perform the operation on all indices
:arg allow_no_indices: Whether to ignore if a wildcard indices
expression resolves into no concrete indices. (This includes `_all`
string or when no indices have been specified)
- :arg expand_wildcards: Whether to expand wildcard expression to concrete
- indices that are open, closed or both., 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 verbose: Includes detailed memory usage by Lucene., default False
+ :arg expand_wildcards: Whether to expand wildcard expression to
+ concrete indices that are open, closed or both. Valid choices: open,
+ closed, none, all Default: open
+ :arg ignore_unavailable: Whether specified concrete indices
+ should be ignored when unavailable (missing or closed)
+ :arg verbose: Includes detailed memory usage by Lucene.
"""
return self.transport.perform_request(
"GET", _make_path(index, "_segments"), params=params
@@ -774,45 +802,44 @@ class IndicesClient(NamespacedClient):
"explain",
"ignore_unavailable",
"lenient",
- "operation_threading",
"q",
"rewrite",
)
- def validate_query(self, index=None, doc_type=None, body=None, params=None):
+ def validate_query(self, body=None, index=None, doc_type=None, params=None):
"""
- Validate a potentially expensive query without executing it.
- ``_
+ Allows a user to validate a potentially expensive query without executing it.
+ ``_
- :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 doc_type: A comma-separated list of document types to restrict the
- operation; leave empty to perform the operation on all types
:arg body: The query definition specified with the Query DSL
- :arg all_shards: Execute validation on all shards instead of one random
- shard per index
+ :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 doc_type: A comma-separated list of document types to
+ restrict the operation; leave empty to perform the operation on all
+ types
+ :arg all_shards: Execute validation on all shards instead of one
+ random shard per 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 analyze_wildcard: Specify whether wildcard and prefix queries
- should be analyzed (default: false)
+ :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', 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', valid
- choices are: 'open', 'closed', 'none', 'all'
+ :arg default_operator: The default operator for query string
+ query (AND or OR) Valid choices: AND, OR Default: 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. Valid choices: open,
+ closed, none, all Default: open
:arg explain: Return detailed information about the error
- :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
- providing text to a numeric field) should be ignored
- :arg operation_threading: TODO: ?
+ :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 providing text to a numeric field) should be ignored
: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.
+ :arg rewrite: Provide a more detailed explanation showing the
+ actual Lucene query that will be executed.
"""
return self.transport.perform_request(
"GET",
@@ -824,36 +851,35 @@ class IndicesClient(NamespacedClient):
@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.
- ``_
+ Clears all or specific caches for one or more indices.
+ ``_
- :arg index: A comma-separated list of index name to limit the operation
+ :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 expand_wildcards: Whether to expand wildcard expression to
+ concrete indices that are open, closed or both. Valid choices: open,
+ closed, none, all Default: open
:arg fielddata: Clear field data
- :arg fields: A comma-separated list of fields to clear when using the
- `field_data` parameter (default: all)
- :arg ignore_unavailable: Whether specified concrete indices should be
- ignored when unavailable (missing or closed)
+ :arg fields: A comma-separated list of fields to clear when
+ using the `fielddata` parameter (default: all)
+ :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
- :arg request_cache: Clear request cache
"""
return self.transport.perform_request(
"POST", _make_path(index, "_cache", "clear"), params=params
@@ -862,17 +888,15 @@ class IndicesClient(NamespacedClient):
@query_params("active_only", "detailed")
def recovery(self, index=None, params=None):
"""
- The indices recovery API provides insight into on-going shard
- recoveries. Recovery status may be reported for specific indices, or
- cluster-wide.
- ``_
+ Returns information about ongoing index shard recoveries.
+ ``_
- :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
- :arg detailed: Whether to display detailed information about shard
- recovery, default False
+ :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
+ :arg detailed: Whether to display detailed information about
+ shard recovery
"""
return self.transport.perform_request(
"GET", _make_path(index, "_recovery"), params=params
@@ -887,23 +911,23 @@ class IndicesClient(NamespacedClient):
)
def upgrade(self, index=None, params=None):
"""
- Upgrade one or more indices to the latest format through an API.
- ``_
+ The _upgrade API is no longer useful and will be removed.
+ ``_
- :arg index: A comma-separated list of index names; use `_all` or empty
- string to perform the operation on all indices
+ :arg index: A comma-separated list of index names; use `_all` or
+ empty string to perform the operation on all indices
:arg allow_no_indices: Whether to ignore if a wildcard indices
expression resolves into no concrete indices. (This includes `_all`
string or when no indices have been specified)
- :arg expand_wildcards: Whether to expand wildcard expression to concrete
- indices that are open, closed or both., 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: false)
+ :arg expand_wildcards: Whether to expand wildcard expression to
+ concrete indices that are open, closed or both. Valid choices: open,
+ closed, none, all Default: open
+ :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: false)
"""
return self.transport.perform_request(
"POST", _make_path(index, "_upgrade"), params=params
@@ -912,19 +936,19 @@ class IndicesClient(NamespacedClient):
@query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable")
def get_upgrade(self, index=None, params=None):
"""
- Monitor how much of one or more index is upgraded.
- ``_
+ The _upgrade API is no longer useful and will be removed.
+ ``_
- :arg index: A comma-separated list of index names; use `_all` or empty
- string to perform the operation on all indices
+ :arg index: A comma-separated list of index names; use `_all` or
+ empty string to perform the operation on all indices
:arg allow_no_indices: Whether to ignore if a wildcard indices
expression resolves into no concrete indices. (This includes `_all`
string or when no indices have been specified)
- :arg expand_wildcards: Whether to expand wildcard expression to concrete
- indices that are open, closed or both., 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 expand_wildcards: Whether to expand wildcard expression to
+ concrete indices that are open, closed or both. Valid choices: open,
+ closed, none, all Default: open
+ :arg ignore_unavailable: Whether specified concrete indices
+ should be ignored when unavailable (missing or closed)
"""
return self.transport.perform_request(
"GET", _make_path(index, "_upgrade"), params=params
@@ -933,53 +957,45 @@ class IndicesClient(NamespacedClient):
@query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable")
def flush_synced(self, index=None, params=None):
"""
- Perform a normal flush, then add a generated unique marker (sync_id) to all shards.
- ``_
+ Performs a synced flush operation on one or more indices.
+ ``_
- :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; use `_all` or
+ empty string for all indices
:arg allow_no_indices: Whether to ignore if a wildcard indices
expression resolves into no concrete indices. (This includes `_all`
string or when no indices have been specified)
- :arg expand_wildcards: Whether to expand wildcard expression to concrete
- indices that are open, closed or both., default 'open', valid
- choices are: 'open', 'closed', 'none', 'all'
- :arg ignore_unavailable: Whether specified concrete indices should be
- ignored when unavailable (missing or closed)
+ :arg expand_wildcards: Whether to expand wildcard expression to
+ concrete indices that are open, closed or both. Valid choices: open,
+ closed, none, all Default: open
+ :arg ignore_unavailable: Whether specified concrete indices
+ should be ignored when unavailable (missing or closed)
"""
return self.transport.perform_request(
"POST", _make_path(index, "_flush", "synced"), params=params
)
@query_params(
- "allow_no_indices",
- "expand_wildcards",
- "ignore_unavailable",
- "operation_threading",
- "status",
+ "allow_no_indices", "expand_wildcards", "ignore_unavailable", "status"
)
def shard_stores(self, index=None, params=None):
"""
- Provides store information for shard copies of indices. Store
- information reports on which nodes shard copies exist, the shard copy
- version, indicating how recent they are, and any exceptions encountered
- while opening the shard index or from earlier engine failure.
- ``_
+ Provides store information for shard copies of indices.
+ ``_
- :arg index: A comma-separated list of index names; use `_all` or empty
- string to perform the operation on all indices
+ :arg index: A comma-separated list of index names; use `_all` or
+ empty string to perform the operation on all indices
:arg allow_no_indices: Whether to ignore if a wildcard indices
expression resolves into no concrete indices. (This includes `_all`
string or when no indices have been specified)
- :arg expand_wildcards: Whether to expand wildcard expression to concrete
- indices that are open, closed or both., 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'
+ :arg expand_wildcards: Whether to expand wildcard expression to
+ concrete indices that are open, closed or both. Valid choices: open,
+ closed, none, all Default: open
+ :arg ignore_unavailable: Whether specified concrete indices
+ should be ignored when unavailable (missing or closed)
+ :arg status: A comma-separated list of statuses used to filter
+ on shards to get store information for Valid choices: green, yellow,
+ red, all
"""
return self.transport.perform_request(
"GET", _make_path(index, "_shard_stores"), params=params
@@ -992,131 +1008,123 @@ class IndicesClient(NamespacedClient):
"ignore_unavailable",
"max_num_segments",
"only_expunge_deletes",
- "operation_threading",
- "wait_for_merge",
)
def forcemerge(self, index=None, params=None):
"""
- The force merge API allows to force merging of one or more indices
- through an API. The merge relates to the number of segments a Lucene
- index holds within each shard. The force merge operation allows to
- reduce the number of segments by merging them.
+ Performs the force merge operation on one or more indices.
+ ``_
- This call will block until the merge is complete. If the http
- connection is lost, the request will continue in the background, and
- any new requests will block until the previous force merge is complete.
- ``_
-
- :arg index: A comma-separated list of index names; use `_all` or empty
- string to perform the operation on all indices
+ :arg index: A comma-separated list of index names; use `_all` or
+ empty string to perform the operation on all indices
:arg allow_no_indices: Whether to ignore if a wildcard indices
expression resolves into no concrete indices. (This includes `_all`
string or when no indices have been specified)
- :arg expand_wildcards: Whether to expand wildcard expression to concrete
- indices that are open, closed or both., 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 (for pre 7.x ES clusters)
+ :arg expand_wildcards: Whether to expand wildcard expression to
+ concrete indices that are open, closed or both. Valid choices: open,
+ closed, none, all Default: open
+ :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
"""
return self.transport.perform_request(
"POST", _make_path(index, "_forcemerge"), params=params
)
- @query_params("master_timeout", "timeout", "wait_for_active_shards")
+ @query_params(
+ "copy_settings", "master_timeout", "timeout", "wait_for_active_shards"
+ )
def shrink(self, index, target, body=None, params=None):
"""
- The shrink index API allows you to shrink an existing index into a new
- index with fewer primary shards. The number of primary shards in the
- target index must be a factor of the shards in the source index. For
- example an index with 8 primary shards can be shrunk into 4, 2 or 1
- primary shards or an index with 15 primary shards can be shrunk into 5,
- 3 or 1. If the number of shards in the index is a prime number it can
- only be shrunk into a single primary shard. Before shrinking, a
- (primary or replica) copy of every shard in the index must be present
- on the same node.
- ``_
+ Allow to shrink an existing index into a new index with fewer primary shards.
+ ``_
:arg index: The name of the source index to shrink
:arg target: The name of the target index to shrink into
- :arg body: The configuration for the target index (`settings` and
- `aliases`)
+ :arg body: The configuration for the target index (`settings`
+ and `aliases`)
+ :arg copy_settings: whether or not to copy settings from the
+ source index (defaults to false)
:arg master_timeout: Specify timeout for connection to master
:arg timeout: Explicit operation timeout
- :arg wait_for_active_shards: Set the number of active shards to wait for
- on the shrunken index before the operation returns.
+ :arg wait_for_active_shards: Set the number of active shards to
+ wait for on the shrunken index before the operation returns.
"""
for param in (index, target):
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")
+
return self.transport.perform_request(
"PUT", _make_path(index, "_shrink", target), params=params, body=body
)
- @query_params("master_timeout", "timeout", "wait_for_active_shards")
+ @query_params(
+ "copy_settings", "master_timeout", "timeout", "wait_for_active_shards"
+ )
def split(self, index, target, body=None, params=None):
"""
- ``_
+ Allows you to split an existing index into a new index with more primary
+ shards.
+ ``_
:arg index: The name of the source index to split
:arg target: The name of the target index to split into
- :arg body: The configuration for the target index (`settings` and
- `aliases`)
+ :arg body: The configuration for the target index (`settings`
+ and `aliases`)
+ :arg copy_settings: whether or not to copy settings from the
+ source index (defaults to false)
:arg master_timeout: Specify timeout for connection to master
:arg timeout: Explicit operation timeout
- :arg wait_for_active_shards: Set the number of active shards to wait for
- on the shrunken index before the operation returns.
+ :arg wait_for_active_shards: Set the number of active shards to
+ wait for on the shrunken index before the operation returns.
"""
for param in (index, target):
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")
+
return self.transport.perform_request(
"PUT", _make_path(index, "_split", target), params=params, body=body
)
@query_params(
"dry_run",
+ "include_type_name",
"master_timeout",
"timeout",
"wait_for_active_shards",
- "include_type_name",
)
- def rollover(self, alias, new_index=None, body=None, params=None):
+ def rollover(self, alias, body=None, new_index=None, params=None):
"""
- The rollover index API rolls an alias over to a new index when the
- existing index is considered to be too large or too old.
-
- The API accepts a single alias name and a list of conditions. The alias
- must point to a single index only. If the index satisfies the specified
- conditions then a new index is created and the alias is switched to
- point to the new alias.
- ``_
+ Updates an alias to point to a new index when the existing index is considered
+ to be too large or too old.
+ ``_
:arg alias: The name of the alias to rollover
+ :arg body: The conditions that needs to be met for executing
+ rollover
:arg new_index: The name of the rollover index
- :arg body: The conditions that needs to be met for executing rollover
- :arg dry_run: If set to true the rollover action will only be validated
- but not actually performed even if a condition matches. The default
- is false
+ :arg dry_run: If set to true the rollover action will only be
+ validated but not actually performed even if a condition matches. The
+ default is false
+ :arg include_type_name: Whether a type should be included in the
+ body of the mappings.
:arg master_timeout: Specify timeout for connection to master
:arg timeout: Explicit operation timeout
- :arg wait_for_active_shards: Set the number of active shards to wait for
- on the newly created rollover index before the operation returns.
- :arg include_type_name: Specify whether requests and responses should include a
- type name (default: depends on Elasticsearch version).
+ :arg wait_for_active_shards: Set the number of active shards to
+ wait for on the newly created rollover index before the operation
+ returns.
"""
if alias in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'alias'.")
+
return self.transport.perform_request(
"POST", _make_path(alias, "_rollover", new_index), params=params, body=body
)
- # X-pack APIS
@query_params(
"allow_no_indices",
"expand_wildcards",
@@ -1133,18 +1141,19 @@ class IndicesClient(NamespacedClient):
: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 expand_wildcards: Whether to expand wildcard expression to
+ concrete indices that are open, closed or both. Valid choices: open,
+ closed, none, all Default: closed
+ :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 wait_for_active_shards: Sets the number of active shards to wait
- for before the operation returns.
+ :arg wait_for_active_shards: Sets the number of active shards to
+ wait for before the operation returns.
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'index'.")
+
return self.transport.perform_request(
"POST", _make_path(index, "_freeze"), params=params
)
@@ -1165,18 +1174,42 @@ class IndicesClient(NamespacedClient):
: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 expand_wildcards: Whether to expand wildcard expression to
+ concrete indices that are open, closed or both. Valid choices: open,
+ closed, none, all Default: closed
+ :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 wait_for_active_shards: Sets the number of active shards to wait
- for before the operation returns.
+ :arg wait_for_active_shards: Sets the number of active shards to
+ wait for before the operation returns.
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'index'.")
+
return self.transport.perform_request(
"POST", _make_path(index, "_unfreeze"), params=params
)
+
+ @query_params("allow_no_indices", "expand_wildcards", "ignore_unavailable")
+ def reload_search_analyzers(self, index, params=None):
+ """
+ ``_
+
+ :arg index: A comma-separated list of index names to reload
+ analyzers for
+ :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. Valid choices: open,
+ closed, none, all Default: open
+ :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'.")
+
+ return self.transport.perform_request(
+ "GET", _make_path(index, "_reload_search_analyzers"), params=params
+ )
diff --git a/elasticsearch/client/ingest.py b/elasticsearch/client/ingest.py
index bc66c331..0ef5af6d 100644
--- a/elasticsearch/client/ingest.py
+++ b/elasticsearch/client/ingest.py
@@ -5,11 +5,13 @@ class IngestClient(NamespacedClient):
@query_params("master_timeout")
def get_pipeline(self, id=None, params=None):
"""
- ``_
+ Returns a pipeline.
+ ``_
- :arg id: Comma separated list of pipeline ids. Wildcards supported
- :arg master_timeout: Explicit operation timeout for connection to master
- node
+ :arg id: Comma separated list of pipeline ids. Wildcards
+ supported
+ :arg master_timeout: Explicit operation timeout for connection
+ to master node
"""
return self.transport.perform_request(
"GET", _make_path("_ingest", "pipeline", id), params=params
@@ -18,17 +20,19 @@ class IngestClient(NamespacedClient):
@query_params("master_timeout", "timeout")
def put_pipeline(self, id, body, params=None):
"""
- ``_
+ Creates or updates a pipeline.
+ ``_
:arg id: Pipeline ID
:arg body: The ingest definition
- :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
"""
for param in (id, body):
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")
+
return self.transport.perform_request(
"PUT", _make_path("_ingest", "pipeline", id), params=params, body=body
)
@@ -36,15 +40,17 @@ class IngestClient(NamespacedClient):
@query_params("master_timeout", "timeout")
def delete_pipeline(self, id, params=None):
"""
- ``_
+ Deletes a pipeline.
+ ``_
:arg id: Pipeline ID
- :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
"""
if id in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'id'.")
+
return self.transport.perform_request(
"DELETE", _make_path("_ingest", "pipeline", id), params=params
)
@@ -52,15 +58,17 @@ class IngestClient(NamespacedClient):
@query_params("verbose")
def simulate(self, body, id=None, params=None):
"""
- ``_
+ Allows to simulate a pipeline with example documents.
+ ``_
:arg body: The simulate definition
:arg id: Pipeline ID
- :arg verbose: Verbose mode. Display data output for each processor in
- executed pipeline, default False
+ :arg verbose: Verbose mode. Display data output for each
+ processor in executed pipeline
"""
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")
+
return self.transport.perform_request(
"GET",
_make_path("_ingest", "pipeline", id, "_simulate"),
@@ -71,7 +79,9 @@ class IngestClient(NamespacedClient):
@query_params()
def processor_grok(self, params=None):
"""
+ Returns a list of the built-in patterns.
``_
+
"""
return self.transport.perform_request(
"GET", "/_ingest/processor/grok", params=params
diff --git a/elasticsearch/client/license.py b/elasticsearch/client/license.py
index 2f0fbc8c..f5e9609f 100644
--- a/elasticsearch/client/license.py
+++ b/elasticsearch/client/license.py
@@ -5,24 +5,26 @@ class LicenseClient(NamespacedClient):
@query_params()
def delete(self, params=None):
"""
- ``_
+ ``_
+
"""
return self.transport.perform_request("DELETE", "/_license", params=params)
@query_params("local")
def get(self, params=None):
"""
- ``_
+ ``_
- :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)
"""
return self.transport.perform_request("GET", "/_license", params=params)
@query_params()
def get_basic_status(self, params=None):
"""
- ``_
+ `