Using Asyncio with Elasticsearch

Starting in elasticsearch-py v7.8.0 for Python 3.6+ the elasticsearch package supports async/await with Asyncio and Aiohttp. You can either install aiohttp directly or use the [async] extra:

$ python -m pip install elasticsearch>=7.8.0 aiohttp

# - OR -

$ python -m pip install elasticsearch[async]>=7.8.0

Note

Async functionality is a new feature of this library in v7.8.0+ so please open an issue if you find an issue or have a question about async support.

Getting Started with Async

After installation all async API endpoints are available via AsyncElasticsearch and are used in the same way as other APIs, just with an extra await:

import asyncio
from elasticsearch import AsyncElasticsearch

es = AsyncElasticsearch()

async def main():
    resp = await es.search(
        index="documents",
        body={"query": {"match_all": {}}},
        size=20,
    )
    print(resp)

loop = asyncio.get_event_loop()
loop.run_until_complete(main())

All APIs that are available under the sync client are also available under the async client.

ASGI Applications and Elastic APM

ASGI (Asynchronous Server Gateway Interface) is a new way to serve Python web applications making use of async I/O to achieve better performance. Some examples of ASGI frameworks include FastAPI, Django 3.0+, and Starlette. If you’re using one of these frameworks along with Elasticsearch then you should be using AsyncElasticsearch to avoid blocking the event loop with synchronous network calls for optimal performance.

Elastic APM also supports tracing of async Elasticsearch queries just the same as synchronous queries. For an example on how to configure AsyncElasticsearch with a popular ASGI framework FastAPI and APM tracing there is a pre-built example in the examples/fastapi-apm directory.

Frequently Asked Questions

NameError / ImportError when importing AsyncElasticsearch?

If when trying to use AsyncElasticsearch and you’re receiving a NameError or ImportError you should ensure that you’re running Python 3.6+ (check with $ python --version) and that you have aiohttp installed in your environment (check with $ python -m pip freeze | grep aiohttp). If either of the above conditions is not met then async support won’t be available.

What about the elasticsearch-async package?

Previously asyncio was supported separately via the elasticsearch-async package. The elasticsearch-async package has been deprecated in favor of AsyncElasticsearch provided by the elasticsearch package in v7.8 and onwards.

Receiving ‘Unclosed client session / connector’ warning?

This warning is created by aiohttp when an open HTTP connection is garbage collected. You’ll typically run into this when closing your application. To resolve the issue ensure that close() is called before the AsyncElasticsearch instance is garbage collected.

For example if using FastAPI that might look like this:

from fastapi import FastAPI
from elasticsearch import AsyncElasticsearch

app = FastAPI()
es = AsyncElasticsearch()

# This gets called once the app is shutting down.
@app.on_event("shutdown")
async def app_shutdown():
    await es.close()

Async Helpers

Async variants of all helpers are available in elasticsearch.helpers and are all prefixed with async_*. You’ll notice that these APIs are identical to the ones in the sync Helpers documentation.

All async helpers that accept an iterator or generator also accept async iterators and async generators.

Bulk and Streaming Bulk

elasticsearch.helpers.async_bulk(client: elasticsearch.AsyncElasticsearch, actions: Union[Iterable[Union[bytes, str, Dict[str, Any]]], AsyncIterable[Union[bytes, str, Dict[str, Any]]]], stats_only: bool = False, ignore_status: Union[int, Collection[int]] = (), *args, **kwargs) → Tuple[int, Union[int, List[Any]]]

Helper for the bulk() api that provides a more human friendly interface - it consumes an iterator of actions and sends them to elasticsearch in chunks. It returns a tuple with summary information - number of successfully executed actions and either list of errors or number of errors if stats_only is set to True. Note that by default we raise a BulkIndexError when we encounter an error so options like stats_only only+ apply when raise_on_error is set to False.

When errors are being collected original document data is included in the error dictionary which can lead to an extra high memory usage. If you need to process a lot of data and want to ignore/collect errors please consider using the async_streaming_bulk() helper which will just return the errors and not store them in memory.

Parameters:
  • client – instance of AsyncElasticsearch to use
  • actions – iterator containing the actions
  • stats_only – if True only report number of successful/failed operations instead of just number of successful and a list of error responses
  • ignore_status – list of HTTP status code that you want to ignore

Any additional keyword arguments will be passed to async_streaming_bulk() which is used to execute the operation, see async_streaming_bulk() for more accepted parameters.

import asyncio
from elasticsearch import AsyncElasticsearch
from elasticsearch.helpers import async_bulk

es = AsyncElasticsearch()

async def gendata():
    mywords = ['foo', 'bar', 'baz']
    for word in mywords:
        yield {
            "_index": "mywords",
            "doc": {"word": word},
        }

async def main():
    await async_bulk(es, gendata())

loop = asyncio.get_event_loop()
loop.run_until_complete(main())
elasticsearch.helpers.async_streaming_bulk(client: elasticsearch.AsyncElasticsearch, actions: Union[Iterable[Union[bytes, str, Dict[str, Any]]], AsyncIterable[Union[bytes, str, Dict[str, Any]]]], chunk_size: int = 500, max_chunk_bytes: int = 104857600, raise_on_error: bool = True, expand_action_callback: Callable[[Union[bytes, str, Dict[str, Any]]], Tuple[Dict[str, Any], Union[None, bytes, Dict[str, Any]]]] = <function expand_action>, raise_on_exception: bool = True, max_retries: int = 0, initial_backoff: float = 2, max_backoff: float = 600, yield_ok: bool = True, ignore_status: Union[int, Collection[int]] = (), *args, **kwargs) → AsyncIterable[Tuple[bool, Dict[str, Any]]]

Streaming bulk consumes actions from the iterable passed in and yields results per action. For non-streaming usecases use async_bulk() which is a wrapper around streaming bulk that returns summary information about the bulk operation once the entire input is consumed and sent.

If you specify max_retries it will also retry any documents that were rejected with a 429 status code. To do this it will wait (by calling asyncio.sleep) for initial_backoff seconds and then, every subsequent rejection for the same chunk, for double the time every time up to max_backoff seconds.

Parameters:
  • client – instance of AsyncElasticsearch to use
  • actions – iterable or async iterable containing the actions to be executed
  • chunk_size – number of docs in one chunk sent to es (default: 500)
  • max_chunk_bytes – the maximum size of the request in bytes (default: 100MB)
  • raise_on_error – raise BulkIndexError containing errors (as .errors) from the execution of the last chunk when some occur. By default we raise.
  • raise_on_exception – if False then don’t propagate exceptions from call to bulk and just report the items that failed as failed.
  • expand_action_callback – callback executed on each action passed in, should return a tuple containing the action line and the data line (None if data line should be omitted).
  • max_retries – maximum number of times a document will be retried when 429 is received, set to 0 (default) for no retries on 429
  • initial_backoff – number of seconds we should wait before the first retry. Any subsequent retries will be powers of initial_backoff * 2**retry_number
  • max_backoff – maximum number of seconds a retry will wait
  • yield_ok – if set to False will skip successful documents in the output
  • ignore_status – list of HTTP status code that you want to ignore
import asyncio
from elasticsearch import AsyncElasticsearch
from elasticsearch.helpers import async_streaming_bulk

es = AsyncElasticsearch()

async def gendata():
    mywords = ['foo', 'bar', 'baz']
    for word in mywords:
        yield {
            "_index": "mywords",
            "word": word,
        }

async def main():
    async for ok, result in async_streaming_bulk(es, gendata()):
        action, result = result.popitem()
        if not ok:
            print("failed to %s document %s" % ())

loop = asyncio.get_event_loop()
loop.run_until_complete(main())

Scan

elasticsearch.helpers.async_scan(client: elasticsearch.AsyncElasticsearch, query: Optional[Any] = None, scroll: str = '5m', raise_on_error: bool = True, preserve_order: bool = False, size: int = 1000, request_timeout: Optional[float] = None, clear_scroll: bool = True, scroll_kwargs: Optional[MutableMapping[str, Any]] = None, **kwargs) → AsyncIterable[Dict[str, Any]]

Simple abstraction on top of the scroll() api - a simple iterator that yields all hits as returned by underlining scroll requests.

By default scan does not return results in any pre-determined order. To have a standard order in the returned documents (either by score or explicit sort definition) when scrolling, use preserve_order=True. This may be an expensive operation and will negate the performance benefits of using scan.

Parameters:
  • client – instance of AsyncElasticsearch to use
  • query – body for the search() api
  • scroll – Specify how long a consistent view of the index should be maintained for scrolled search
  • raise_on_error – raises an exception (ScanError) if an error is encountered (some shards fail to execute). By default we raise.
  • preserve_order – don’t set the search_type to scan - this will cause the scroll to paginate with preserving the order. Note that this can be an extremely expensive operation and can easily lead to unpredictable results, use with caution.
  • size – size (per shard) of the batch send at each iteration.
  • request_timeout – explicit timeout for each call to scan
  • clear_scroll – explicitly calls delete on the scroll id via the clear scroll API at the end of the method on completion or error, defaults to true.
  • scroll_kwargs – additional kwargs to be passed to scroll()

Any additional keyword arguments will be passed to the initial search() call:

async_scan(
    es,
    query={"query": {"match": {"title": "python"}}},
    index="orders-*"
)
import asyncio
from elasticsearch import AsyncElasticsearch
from elasticsearch.helpers import async_scan

es = AsyncElasticsearch()

async def main():
    async for doc in async_scan(
        client=es,
        query={"query": {"match": {"title": "python"}}},
        index="orders-*"
    ):
        print(doc)

loop = asyncio.get_event_loop()
loop.run_until_complete(main())

Reindex

elasticsearch.helpers.async_reindex(client: elasticsearch.AsyncElasticsearch, source_index: Union[str, Collection[str]], target_index: str, query: Any = None, target_client: Optional[elasticsearch.AsyncElasticsearch] = None, chunk_size: int = 500, scroll: str = '5m', op_type: Optional[str] = None, scan_kwargs: MutableMapping[str, Any] = {}, bulk_kwargs: MutableMapping[str, Any] = {}) → Tuple[int, Union[int, List[Any]]]

Reindex all documents from one index that satisfy a given query to another, potentially (if target_client is specified) on a different cluster. If you don’t specify the query you will reindex all the documents.

Since 2.3 a reindex() api is available as part of elasticsearch itself. It is recommended to use the api instead of this helper wherever possible. The helper is here mostly for backwards compatibility and for situations where more flexibility is needed.

Note

This helper doesn’t transfer mappings, just the data.

Parameters:
  • client – instance of AsyncElasticsearch to use (for read if target_client is specified as well)
  • source_index – index (or list of indices) to read documents from
  • target_index – name of the index in the target cluster to populate
  • query – body for the search() api
  • target_client – optional, is specified will be used for writing (thus enabling reindex between clusters)
  • chunk_size – number of docs in one chunk sent to es (default: 500)
  • scroll – Specify how long a consistent view of the index should be maintained for scrolled search
  • op_type – Explicit operation type. Defaults to ‘_index’. Data streams must be set to ‘create’. If not specified, will auto-detect if target_index is a data stream.
  • scan_kwargs – additional kwargs to be passed to async_scan()
  • bulk_kwargs – additional kwargs to be passed to async_bulk()

API Reference

The API of AsyncElasticsearch is nearly identical to the API of Elasticsearch with the exception that every API call like search() is an async function and requires an await to properly return the response body.

AsyncElasticsearch

Note

To reference Elasticsearch APIs that are namespaced like .indices.create() refer to the sync API reference. These APIs are identical between sync and async.

class elasticsearch.AsyncElasticsearch(hosts: Union[str, List[Union[str, Mapping[str, Union[str, int]], elastic_transport.NodeConfig]], None] = None, *, cloud_id: Optional[str] = None, api_key: Union[str, Tuple[str, str], None] = None, basic_auth: Union[str, Tuple[str, str], None] = None, bearer_auth: Optional[str] = None, opaque_id: Optional[str] = None, headers: Union[elastic_transport.client_utils.DefaultType, Mapping[str, str]] = <DEFAULT>, connections_per_node: Union[elastic_transport.client_utils.DefaultType, int] = <DEFAULT>, http_compress: Union[elastic_transport.client_utils.DefaultType, bool] = <DEFAULT>, verify_certs: Union[elastic_transport.client_utils.DefaultType, bool] = <DEFAULT>, ca_certs: Union[elastic_transport.client_utils.DefaultType, str] = <DEFAULT>, client_cert: Union[elastic_transport.client_utils.DefaultType, str] = <DEFAULT>, client_key: Union[elastic_transport.client_utils.DefaultType, str] = <DEFAULT>, ssl_assert_hostname: Union[elastic_transport.client_utils.DefaultType, str] = <DEFAULT>, ssl_assert_fingerprint: Union[elastic_transport.client_utils.DefaultType, str] = <DEFAULT>, ssl_version: Union[elastic_transport.client_utils.DefaultType, int] = <DEFAULT>, ssl_context: Union[elastic_transport.client_utils.DefaultType, Any] = <DEFAULT>, ssl_show_warn: Union[elastic_transport.client_utils.DefaultType, bool] = <DEFAULT>, transport_class: Type[elastic_transport.AsyncTransport] = <class 'elastic_transport.AsyncTransport'>, request_timeout: Union[elastic_transport.client_utils.DefaultType, None, float] = <DEFAULT>, node_class: Union[elastic_transport.client_utils.DefaultType, Type[elastic_transport.BaseNode]] = <DEFAULT>, node_pool_class: Union[elastic_transport.client_utils.DefaultType, Type[elastic_transport.NodePool]] = <DEFAULT>, randomize_nodes_in_pool: Union[elastic_transport.client_utils.DefaultType, bool] = <DEFAULT>, node_selector_class: Union[elastic_transport.client_utils.DefaultType, Type[elastic_transport.NodeSelector]] = <DEFAULT>, dead_node_backoff_factor: Union[elastic_transport.client_utils.DefaultType, float] = <DEFAULT>, max_dead_node_backoff: Union[elastic_transport.client_utils.DefaultType, float] = <DEFAULT>, serializer: Optional[elastic_transport.Serializer] = None, serializers: Union[elastic_transport.client_utils.DefaultType, Mapping[str, elastic_transport.Serializer]] = <DEFAULT>, default_mimetype: str = 'application/json', max_retries: Union[elastic_transport.client_utils.DefaultType, int] = <DEFAULT>, retry_on_status: Union[elastic_transport.client_utils.DefaultType, int, Collection[int]] = <DEFAULT>, retry_on_timeout: Union[elastic_transport.client_utils.DefaultType, bool] = <DEFAULT>, sniff_on_start: Union[elastic_transport.client_utils.DefaultType, bool] = <DEFAULT>, sniff_before_requests: Union[elastic_transport.client_utils.DefaultType, bool] = <DEFAULT>, sniff_on_node_failure: Union[elastic_transport.client_utils.DefaultType, bool] = <DEFAULT>, sniff_timeout: Union[elastic_transport.client_utils.DefaultType, None, float] = <DEFAULT>, min_delay_between_sniffing: Union[elastic_transport.client_utils.DefaultType, None, float] = <DEFAULT>, sniffed_node_callback: Optional[Callable[[Dict[str, Any], elastic_transport.NodeConfig], Optional[elastic_transport.NodeConfig]]] = None, meta_header: Union[elastic_transport.client_utils.DefaultType, bool] = <DEFAULT>, timeout: Union[elastic_transport.client_utils.DefaultType, None, float] = <DEFAULT>, randomize_hosts: Union[elastic_transport.client_utils.DefaultType, bool] = <DEFAULT>, host_info_callback: Optional[Callable[[Dict[str, Any], Dict[str, Union[str, int]]], Optional[Dict[str, Union[str, int]]]]] = None, sniffer_timeout: Union[elastic_transport.client_utils.DefaultType, None, float] = <DEFAULT>, sniff_on_connection_fail: Union[elastic_transport.client_utils.DefaultType, bool] = <DEFAULT>, http_auth: Union[elastic_transport.client_utils.DefaultType, Any] = <DEFAULT>, maxsize: Union[elastic_transport.client_utils.DefaultType, int] = <DEFAULT>, _transport: Optional[elastic_transport.AsyncTransport] = None)

Elasticsearch low-level client. Provides a straightforward mapping from Python to Elasticsearch REST APIs.

The client instance has additional attributes to update APIs in different namespaces such as async_search, indices, security, and more:

client = Elasticsearch("http://localhost:9200")

# Get Document API
client.get(index="*", id="1")

# Get Index API
client.indices.get(index="*")

Transport options can be set on the client constructor or using the options() method:

# Set 'api_key' on the constructor
client = Elasticsearch(
    "http://localhost:9200",
    api_key=("id", "api_key")
)
client.search(...)

# Set 'api_key' per request
client.options(api_key=("id", "api_key")).search(...)
bulk(*, operations: Union[List[Mapping[str, Any]], Tuple[Mapping[str, Any], ...]], index: Optional[str] = None, error_trace: Optional[bool] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, pipeline: Optional[str] = None, pretty: Optional[bool] = None, refresh: Union[t.Literal['false', 'true', 'wait_for'], bool, str, None] = None, require_alias: Optional[bool] = None, routing: Optional[str] = None, source: Union[bool, str, List[str], Tuple[str, ...], None] = None, source_excludes: Union[str, List[str], Tuple[str, ...], None] = None, source_includes: Union[str, List[str], Tuple[str, ...], None] = None, timeout: Union[int, str, None] = None, wait_for_active_shards: Union[int, t.Literal['all', 'index-setting'], str, None] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Allows to perform multiple index/update/delete operations in a single request.

https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-bulk.html

Parameters:
  • operations
  • index – Default index for items which don’t provide one
  • pipeline – The pipeline id to preprocess incoming documents with
  • 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.
  • require_alias – Sets require_alias for all incoming documents. Defaults to unset (false)
  • routing – Specific routing value
  • 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
  • source_excludes – Default list of fields to exclude from the returned _source field, can be overridden on each sub-request
  • source_includes – Default list of fields to extract and return from the _source field, can be overridden on each sub-request
  • timeout – Explicit operation timeout
  • 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)
clear_scroll(*, error_trace: Optional[bool] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, pretty: Optional[bool] = None, scroll_id: Union[str, List[str], Tuple[str, ...], None] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Explicitly clears the search context for a scroll.

https://www.elastic.co/guide/en/elasticsearch/reference/master/clear-scroll-api.html

Parameters:scroll_id
close() → None

Closes the Transport and all internal connections

close_point_in_time(*, id: str, error_trace: Optional[bool] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, pretty: Optional[bool] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Close a point in time

https://www.elastic.co/guide/en/elasticsearch/reference/master/point-in-time-api.html

Parameters:id
count(*, index: Union[str, List[str], Tuple[str, ...], None] = None, allow_no_indices: Optional[bool] = None, analyze_wildcard: Optional[bool] = None, analyzer: Optional[str] = None, default_operator: Union[t.Literal['and', 'or'], str, None] = None, df: Optional[str] = None, error_trace: Optional[bool] = None, expand_wildcards: Union[t.Literal['all', 'closed', 'hidden', 'none', 'open'], str, List[Union[t.Literal['all', 'closed', 'hidden', 'none', 'open'], str]], Tuple[Union[t.Literal['all', 'closed', 'hidden', 'none', 'open'], str], ...], None] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, ignore_throttled: Optional[bool] = None, ignore_unavailable: Optional[bool] = None, lenient: Optional[bool] = None, min_score: Optional[float] = None, preference: Optional[str] = None, pretty: Optional[bool] = None, q: Optional[str] = None, query: Optional[Mapping[str, Any]] = None, routing: Optional[str] = None, terminate_after: Optional[int] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Returns number of documents matching a query.

https://www.elastic.co/guide/en/elasticsearch/reference/master/search-count.html

Parameters:
  • index – A comma-separated list of indices to restrict the results
  • 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)
  • analyze_wildcard – Specify whether wildcard and prefix queries should be analyzed (default: false)
  • analyzer – The analyzer to use for the query string
  • default_operator – The default operator for query string query (AND or OR)
  • df – The field to use as default where no field prefix is given in the query string
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both.
  • ignore_throttled – Whether specified concrete, expanded or aliased indices should be ignored when throttled
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • lenient – Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
  • min_score – Include only documents with a specific _score value in the result
  • preference – Specify the node or shard the operation should be performed on (default: random)
  • q – Query in the Lucene query string syntax
  • query
  • routing – A comma-separated list of specific routing values
  • terminate_after – The maximum count for each shard, upon reaching which the query execution will terminate early
create(*, index: str, id: str, document: Mapping[str, Any], error_trace: Optional[bool] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, pipeline: Optional[str] = None, pretty: Optional[bool] = None, refresh: Union[t.Literal['false', 'true', 'wait_for'], bool, str, None] = None, routing: Optional[str] = None, timeout: Union[int, str, None] = None, version: Optional[int] = None, version_type: Union[t.Literal['external', 'external_gte', 'force', 'internal'], str, None] = None, wait_for_active_shards: Union[int, t.Literal['all', 'index-setting'], str, None] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Creates a new document in the index. Returns a 409 response when a document with a same ID already exists in the index.

https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html

Parameters:
  • index – The name of the index
  • id – Document ID
  • document
  • pipeline – The pipeline id to preprocess incoming documents with
  • 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.
  • routing – Specific routing value
  • timeout – Explicit operation timeout
  • version – Explicit version number for concurrency control
  • version_type – Specific version type
  • 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)
delete(*, index: str, id: str, error_trace: Optional[bool] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, if_primary_term: Optional[int] = None, if_seq_no: Optional[int] = None, pretty: Optional[bool] = None, refresh: Union[t.Literal['false', 'true', 'wait_for'], bool, str, None] = None, routing: Optional[str] = None, timeout: Union[int, str, None] = None, version: Optional[int] = None, version_type: Union[t.Literal['external', 'external_gte', 'force', 'internal'], str, None] = None, wait_for_active_shards: Union[int, t.Literal['all', 'index-setting'], str, None] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Removes a document from the index.

https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete.html

Parameters:
  • index – The name of the index
  • id – The document ID
  • if_primary_term – only perform the delete operation if the last operation that has changed the document has the specified primary term
  • if_seq_no – only perform the delete operation if the last operation that has changed the document has the specified sequence number
  • 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.
  • routing – Specific routing value
  • timeout – Explicit operation timeout
  • version – Explicit version number for concurrency control
  • version_type – Specific version type
  • 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)
delete_by_query(*, index: Union[str, List[str], Tuple[str, ...]], allow_no_indices: Optional[bool] = None, analyze_wildcard: Optional[bool] = None, analyzer: Optional[str] = None, conflicts: Union[t.Literal['abort', 'proceed'], str, None] = None, default_operator: Union[t.Literal['and', 'or'], str, None] = None, df: Optional[str] = None, error_trace: Optional[bool] = None, expand_wildcards: Union[t.Literal['all', 'closed', 'hidden', 'none', 'open'], str, List[Union[t.Literal['all', 'closed', 'hidden', 'none', 'open'], str]], Tuple[Union[t.Literal['all', 'closed', 'hidden', 'none', 'open'], str], ...], None] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, from_: Optional[int] = None, human: Optional[bool] = None, ignore_unavailable: Optional[bool] = None, lenient: Optional[bool] = None, max_docs: Optional[int] = None, preference: Optional[str] = None, pretty: Optional[bool] = None, q: Optional[str] = None, query: Optional[Mapping[str, Any]] = None, refresh: Optional[bool] = None, request_cache: Optional[bool] = None, requests_per_second: Optional[int] = None, routing: Optional[str] = None, scroll: Union[int, str, None] = None, scroll_size: Optional[int] = None, search_timeout: Union[int, str, None] = None, search_type: Union[t.Literal['dfs_query_then_fetch', 'query_then_fetch'], str, None] = None, slice: Optional[Mapping[str, Any]] = None, slices: Union[int, t.Literal['auto'], str, None] = None, sort: Union[List[str], Tuple[str, ...], None] = None, stats: Union[List[str], Tuple[str, ...], None] = None, terminate_after: Optional[int] = None, timeout: Union[int, str, None] = None, version: Optional[bool] = None, wait_for_active_shards: Union[int, t.Literal['all', 'index-setting'], str, None] = None, wait_for_completion: Optional[bool] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Deletes documents matching the provided query.

https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete-by-query.html

Parameters:
  • index – A comma-separated list of index names to search; use _all or empty string to perform the operation on all indices
  • 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)
  • analyze_wildcard – Specify whether wildcard and prefix queries should be analyzed (default: false)
  • analyzer – The analyzer to use for the query string
  • conflicts – What to do when the delete by query hits version conflicts?
  • default_operator – The default operator for query string query (AND or OR)
  • df – The field to use as default where no field prefix is given in the query string
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both.
  • from – Starting offset (default: 0)
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • lenient – Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
  • max_docs
  • preference – Specify the node or shard the operation should be performed on (default: random)
  • q – Query in the Lucene query string syntax
  • query
  • refresh – Should the affected indexes be refreshed?
  • request_cache – Specify if request cache should be used for this request or not, defaults to index level setting
  • requests_per_second – The throttle for this request in sub-requests per second. -1 means no throttle.
  • routing – A comma-separated list of specific routing values
  • scroll – Specify how long a consistent view of the index should be maintained for scrolled search
  • scroll_size – Size on the scroll request powering the delete by query
  • search_timeout – Explicit timeout for each search request. Defaults to no timeout.
  • search_type – Search operation type
  • slice
  • slices – The number of slices this task should be divided into. Defaults to 1, meaning the task isn’t sliced into subtasks. Can be set to auto.
  • sort – A comma-separated list of <field>:<direction> pairs
  • stats – Specific ‘tag’ of the request for logging and statistical purposes
  • terminate_after – The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
  • timeout – Time each individual bulk request should wait for shards that are unavailable.
  • version – Specify whether to return document version as part of a hit
  • 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)
  • wait_for_completion – Should the request should block until the delete by query is complete.
delete_by_query_rethrottle(*, task_id: str, error_trace: Optional[bool] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, pretty: Optional[bool] = None, requests_per_second: Optional[int] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Changes the number of requests per second for a particular Delete By Query operation.

https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete-by-query.html

Parameters:
  • task_id – The task id to rethrottle
  • requests_per_second – The throttle to set on this request in floating sub-requests per second. -1 means set no throttle.
delete_script(*, id: str, error_trace: Optional[bool] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, master_timeout: Union[int, str, None] = None, pretty: Optional[bool] = None, timeout: Union[int, str, None] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Deletes a script.

https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html

Parameters:
  • id – Script ID
  • master_timeout – Specify timeout for connection to master
  • timeout – Explicit operation timeout
exists(*, index: str, id: str, error_trace: Optional[bool] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, preference: Optional[str] = None, pretty: Optional[bool] = None, realtime: Optional[bool] = None, refresh: Optional[bool] = None, routing: Optional[str] = None, source: Union[bool, str, List[str], Tuple[str, ...], None] = None, source_excludes: Union[str, List[str], Tuple[str, ...], None] = None, source_includes: Union[str, List[str], Tuple[str, ...], None] = None, stored_fields: Union[str, List[str], Tuple[str, ...], None] = None, version: Optional[int] = None, version_type: Union[t.Literal['external', 'external_gte', 'force', 'internal'], str, None] = None) → elastic_transport.HeadApiResponse

Returns information about whether a document exists in an index.

https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html

Parameters:
  • index – The name of the index
  • id – The document ID
  • preference – Specify the node or shard the operation should be performed on (default: random)
  • realtime – Specify whether to perform the operation in realtime or search mode
  • refresh – Refresh the shard containing the document before performing the operation
  • routing – Specific routing value
  • source – True or false to return the _source field or not, or a list of fields to return
  • source_excludes – A list of fields to exclude from the returned _source field
  • source_includes – A list of fields to extract and return from the _source field
  • stored_fields – A comma-separated list of stored fields to return in the response
  • version – Explicit version number for concurrency control
  • version_type – Specific version type
exists_source(*, index: str, id: str, error_trace: Optional[bool] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, preference: Optional[str] = None, pretty: Optional[bool] = None, realtime: Optional[bool] = None, refresh: Optional[bool] = None, routing: Optional[str] = None, source: Union[bool, str, List[str], Tuple[str, ...], None] = None, source_excludes: Union[str, List[str], Tuple[str, ...], None] = None, source_includes: Union[str, List[str], Tuple[str, ...], None] = None, version: Optional[int] = None, version_type: Union[t.Literal['external', 'external_gte', 'force', 'internal'], str, None] = None) → elastic_transport.HeadApiResponse

Returns information about whether a document source exists in an index.

https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html

Parameters:
  • index – The name of the index
  • id – The document ID
  • preference – Specify the node or shard the operation should be performed on (default: random)
  • realtime – Specify whether to perform the operation in realtime or search mode
  • refresh – Refresh the shard containing the document before performing the operation
  • routing – Specific routing value
  • source – True or false to return the _source field or not, or a list of fields to return
  • source_excludes – A list of fields to exclude from the returned _source field
  • source_includes – A list of fields to extract and return from the _source field
  • version – Explicit version number for concurrency control
  • version_type – Specific version type
explain(*, index: str, id: str, analyze_wildcard: Optional[bool] = None, analyzer: Optional[str] = None, default_operator: Union[t.Literal['and', 'or'], str, None] = None, df: Optional[str] = None, error_trace: Optional[bool] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, lenient: Optional[bool] = None, preference: Optional[str] = None, pretty: Optional[bool] = None, q: Optional[str] = None, query: Optional[Mapping[str, Any]] = None, routing: Optional[str] = None, source: Union[bool, str, List[str], Tuple[str, ...], None] = None, source_excludes: Union[str, List[str], Tuple[str, ...], None] = None, source_includes: Union[str, List[str], Tuple[str, ...], None] = None, stored_fields: Union[str, List[str], Tuple[str, ...], None] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Returns information about why a specific matches (or doesn’t match) a query.

https://www.elastic.co/guide/en/elasticsearch/reference/master/search-explain.html

Parameters:
  • index – The name of the index
  • id – The document ID
  • analyze_wildcard – Specify whether wildcards and prefix queries in the query string query should be analyzed (default: false)
  • analyzer – The analyzer for the query string query
  • default_operator – The default operator for query string query (AND or OR)
  • df – The default field for query string query (default: _all)
  • lenient – Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
  • preference – Specify the node or shard the operation should be performed on (default: random)
  • q – Query in the Lucene query string syntax
  • query
  • routing – Specific routing value
  • source – True or false to return the _source field or not, or a list of fields to return
  • source_excludes – A list of fields to exclude from the returned _source field
  • source_includes – A list of fields to extract and return from the _source field
  • stored_fields – A comma-separated list of stored fields to return in the response
field_caps(*, fields: Union[str, List[str], Tuple[str, ...]], index: Union[str, List[str], Tuple[str, ...], None] = None, allow_no_indices: Optional[bool] = None, error_trace: Optional[bool] = None, expand_wildcards: Union[t.Literal['all', 'closed', 'hidden', 'none', 'open'], str, List[Union[t.Literal['all', 'closed', 'hidden', 'none', 'open'], str]], Tuple[Union[t.Literal['all', 'closed', 'hidden', 'none', 'open'], str], ...], None] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, filters: Optional[str] = None, human: Optional[bool] = None, ignore_unavailable: Optional[bool] = None, include_unmapped: Optional[bool] = None, index_filter: Optional[Mapping[str, Any]] = None, pretty: Optional[bool] = None, runtime_mappings: Optional[Mapping[str, Union[Mapping[str, Any], List[Mapping[str, Any]], Tuple[Mapping[str, Any], ...]]]] = None, types: Union[List[str], Tuple[str, ...], None] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Returns the information about the capabilities of fields among multiple indices.

https://www.elastic.co/guide/en/elasticsearch/reference/master/search-field-caps.html

Parameters:
  • fields – Comma-separated list of fields to retrieve capabilities for. Wildcard (*) expressions are supported.
  • index – Comma-separated list of data streams, indices, and aliases used to limit the request. Supports wildcards (*). To target all data streams and indices, omit this parameter or use * or _all.
  • allow_no_indices – If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. This behavior applies even if the request targets other open indices. For example, a request targeting foo*,bar* returns an error if an index starts with foo but no index starts with bar.
  • expand_wildcards – Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as open,hidden.
  • filters – An optional set of filters: can include +metadata,-metadata,-nested,-multifield,-parent
  • ignore_unavailable – If true, missing or closed indices are not included in the response.
  • include_unmapped – If true, unmapped fields are included in the response.
  • index_filter – Allows to filter indices if the provided query rewrites to match_none on every shard.
  • runtime_mappings – Defines ad-hoc runtime fields in the request similar to the way it is done in search requests. These fields exist only as part of the query and take precedence over fields defined with the same name in the index mappings.
  • types – Only return results for fields that have one of the types in the list
get(*, index: str, id: str, error_trace: Optional[bool] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, preference: Optional[str] = None, pretty: Optional[bool] = None, realtime: Optional[bool] = None, refresh: Optional[bool] = None, routing: Optional[str] = None, source: Union[bool, str, List[str], Tuple[str, ...], None] = None, source_excludes: Union[str, List[str], Tuple[str, ...], None] = None, source_includes: Union[str, List[str], Tuple[str, ...], None] = None, stored_fields: Union[str, List[str], Tuple[str, ...], None] = None, version: Optional[int] = None, version_type: Union[t.Literal['external', 'external_gte', 'force', 'internal'], str, None] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Returns a document.

https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html

Parameters:
  • index – Name of the index that contains the document.
  • id – Unique identifier of the document.
  • preference – Specifies the node or shard the operation should be performed on. Random by default.
  • realtime – Boolean) If true, the request is real-time as opposed to near-real-time.
  • refresh – If true, Elasticsearch refreshes the affected shards to make this operation visible to search. If false, do nothing with refreshes.
  • routing – Target the specified primary shard.
  • source – True or false to return the _source field or not, or a list of fields to return.
  • source_excludes – A comma-separated list of source fields to exclude in the response.
  • source_includes – A comma-separated list of source fields to include in the response.
  • stored_fields – A comma-separated list of stored fields to return in the response
  • version – Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed.
  • version_type – Specific version type: internal, external, external_gte.
get_script(*, id: str, error_trace: Optional[bool] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, master_timeout: Union[int, str, None] = None, pretty: Optional[bool] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Returns a script.

https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html

Parameters:
  • id – Script ID
  • master_timeout – Specify timeout for connection to master
get_script_context(*, error_trace: Optional[bool] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, pretty: Optional[bool] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Returns all script contexts.

https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-contexts.html

get_script_languages(*, error_trace: Optional[bool] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, pretty: Optional[bool] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Returns available script types, languages and contexts

https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html

get_source(*, index: str, id: str, preference: Optional[str] = None, realtime: Optional[bool] = None, refresh: Optional[bool] = None, routing: Optional[str] = None, source: Union[bool, str, List[str], Tuple[str, ...], None] = None, source_excludes: Union[str, List[str], Tuple[str, ...], None] = None, source_includes: Union[str, List[str], Tuple[str, ...], None] = None, stored_fields: Union[str, List[str], Tuple[str, ...], None] = None, version: Optional[int] = None, version_type: Union[t.Literal['external', 'external_gte', 'force', 'internal'], str, None] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Returns the source of a document.

https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html

Parameters:
  • index – Name of the index that contains the document.
  • id – Unique identifier of the document.
  • preference – Specifies the node or shard the operation should be performed on. Random by default.
  • realtime – Boolean) If true, the request is real-time as opposed to near-real-time.
  • refresh – If true, Elasticsearch refreshes the affected shards to make this operation visible to search. If false, do nothing with refreshes.
  • routing – Target the specified primary shard.
  • source – True or false to return the _source field or not, or a list of fields to return.
  • source_excludes – A comma-separated list of source fields to exclude in the response.
  • source_includes – A comma-separated list of source fields to include in the response.
  • stored_fields
  • version – Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed.
  • version_type – Specific version type: internal, external, external_gte.
index(*, index: str, document: Mapping[str, Any], id: Optional[str] = None, error_trace: Optional[bool] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, if_primary_term: Optional[int] = None, if_seq_no: Optional[int] = None, op_type: Union[t.Literal['create', 'index'], str, None] = None, pipeline: Optional[str] = None, pretty: Optional[bool] = None, refresh: Union[t.Literal['false', 'true', 'wait_for'], bool, str, None] = None, require_alias: Optional[bool] = None, routing: Optional[str] = None, timeout: Union[int, str, None] = None, version: Optional[int] = None, version_type: Union[t.Literal['external', 'external_gte', 'force', 'internal'], str, None] = None, wait_for_active_shards: Union[int, t.Literal['all', 'index-setting'], str, None] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Creates or updates a document in an index.

https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html

Parameters:
  • index – The name of the index
  • document
  • id – Document ID
  • if_primary_term – only perform the index operation if the last operation that has changed the document has the specified primary term
  • if_seq_no – only perform the index operation if the last operation that has changed the document has the specified sequence number
  • 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
  • pipeline – The pipeline id to preprocess incoming documents with
  • 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.
  • require_alias – When true, requires destination to be an alias. Default is false
  • routing – Specific routing value
  • timeout – Explicit operation timeout
  • version – Explicit version number for concurrency control
  • version_type – Specific version type
  • 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)
info(*, error_trace: Optional[bool] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, pretty: Optional[bool] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Returns basic information about the cluster.

https://www.elastic.co/guide/en/elasticsearch/reference/master/index.html

Performs a kNN search.

https://www.elastic.co/guide/en/elasticsearch/reference/master/search-search.html

Parameters:
  • index – A comma-separated list of index names to search; use _all or to perform the operation on all indices
  • knn – kNN query to execute
  • docvalue_fields – The request returns doc values for field names matching these patterns in the hits.fields property of the response. Accepts wildcard (*) patterns.
  • fields – The request returns values for field names matching these patterns in the hits.fields property of the response. Accepts wildcard (*) patterns.
  • filter – Query to filter the documents that can match. The kNN search will return the top k documents that also match this filter. The value can be a single query or a list of queries. If filter isn’t provided, all documents are allowed to match.
  • routing – A comma-separated list of specific routing values
  • source – Indicates which source fields are returned for matching documents. These fields are returned in the hits._source property of the search response.
  • stored_fields – List of stored fields to return as part of a hit. If no fields are specified, no stored fields are included in the response. If this field is specified, the _source parameter defaults to false. You can pass _source: true to return both source fields and stored fields in the search response.
mget(*, index: Optional[str] = None, docs: Union[List[Mapping[str, Any]], Tuple[Mapping[str, Any], ...], None] = None, error_trace: Optional[bool] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, ids: Union[str, List[str], Tuple[str, ...], None] = None, preference: Optional[str] = None, pretty: Optional[bool] = None, realtime: Optional[bool] = None, refresh: Optional[bool] = None, routing: Optional[str] = None, source: Union[bool, str, List[str], Tuple[str, ...], None] = None, source_excludes: Union[str, List[str], Tuple[str, ...], None] = None, source_includes: Union[str, List[str], Tuple[str, ...], None] = None, stored_fields: Union[str, List[str], Tuple[str, ...], None] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Allows to get multiple documents in one request.

https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-multi-get.html

Parameters:
  • index – Name of the index to retrieve documents from when ids are specified, or when a document in the docs array does not specify an index.
  • docs – The documents you want to retrieve. Required if no index is specified in the request URI.
  • ids – The IDs of the documents you want to retrieve. Allowed when the index is specified in the request URI.
  • preference – Specifies the node or shard the operation should be performed on. Random by default.
  • realtime – If true, the request is real-time as opposed to near-real-time.
  • refresh – If true, the request refreshes relevant shards before retrieving documents.
  • routing – Custom value used to route operations to a specific shard.
  • source – True or false to return the _source field or not, or a list of fields to return.
  • source_excludes – A comma-separated list of source fields to exclude from the response. You can also use this parameter to exclude fields from the subset specified in _source_includes query parameter.
  • source_includes – A comma-separated list of source fields to include in the response. If this parameter is specified, only these source fields are returned. You can exclude fields from this subset using the _source_excludes query parameter. If the _source parameter is false, this parameter is ignored.
  • stored_fields – If true, retrieves the document fields stored in the index rather than the document _source.
msearch(*, searches: Union[List[Mapping[str, Any]], Tuple[Mapping[str, Any], ...]], index: Union[str, List[str], Tuple[str, ...], None] = None, allow_no_indices: Optional[bool] = None, ccs_minimize_roundtrips: Optional[bool] = None, error_trace: Optional[bool] = None, expand_wildcards: Union[t.Literal['all', 'closed', 'hidden', 'none', 'open'], str, List[Union[t.Literal['all', 'closed', 'hidden', 'none', 'open'], str]], Tuple[Union[t.Literal['all', 'closed', 'hidden', 'none', 'open'], str], ...], None] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, ignore_throttled: Optional[bool] = None, ignore_unavailable: Optional[bool] = None, max_concurrent_searches: Optional[int] = None, max_concurrent_shard_requests: Optional[int] = None, pre_filter_shard_size: Optional[int] = None, pretty: Optional[bool] = None, rest_total_hits_as_int: Optional[bool] = None, routing: Optional[str] = None, search_type: Union[t.Literal['dfs_query_then_fetch', 'query_then_fetch'], str, None] = None, typed_keys: Optional[bool] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Allows to execute several search operations in one request.

https://www.elastic.co/guide/en/elasticsearch/reference/master/search-multi-search.html

Parameters:
  • searches
  • index – Comma-separated list of data streams, indices, and index aliases to search.
  • allow_no_indices – If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. This behavior applies even if the request targets other open indices. For example, a request targeting foo*,bar* returns an error if an index starts with foo but no index starts with bar.
  • ccs_minimize_roundtrips – If true, network roundtrips between the coordinating node and remote clusters are minimized for cross-cluster search requests.
  • expand_wildcards – Type of index that wildcard expressions can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.
  • ignore_throttled – If true, concrete, expanded or aliased indices are ignored when frozen.
  • ignore_unavailable – If true, missing or closed indices are not included in the response.
  • max_concurrent_searches – Maximum number of concurrent searches the multi search API can execute.
  • max_concurrent_shard_requests – Maximum number of concurrent shard requests that each sub-search request executes per node.
  • pre_filter_shard_size – Defines 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 its rewrite method i.e., if date filters are mandatory to match but the shard bounds and the query are disjoint.
  • rest_total_hits_as_int – If true, hits.total are returned as an integer in the response. Defaults to false, which returns an object.
  • routing – Custom routing value used to route search operations to a specific shard.
  • search_type – Indicates whether global term and document frequencies should be used when scoring returned documents.
  • typed_keys – Specifies whether aggregation and suggester names should be prefixed by their respective types in the response.
msearch_template(*, search_templates: Union[List[Mapping[str, Any]], Tuple[Mapping[str, Any], ...]], index: Union[str, List[str], Tuple[str, ...], None] = None, ccs_minimize_roundtrips: Optional[bool] = None, error_trace: Optional[bool] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, max_concurrent_searches: Optional[int] = None, pretty: Optional[bool] = None, rest_total_hits_as_int: Optional[bool] = None, search_type: Union[t.Literal['dfs_query_then_fetch', 'query_then_fetch'], str, None] = None, typed_keys: Optional[bool] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Allows to execute several search template operations in one request.

https://www.elastic.co/guide/en/elasticsearch/reference/master/search-multi-search.html

Parameters:
  • search_templates
  • index – A comma-separated list of index names to use as default
  • ccs_minimize_roundtrips – Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution
  • max_concurrent_searches – Controls the maximum number of concurrent searches the multi search api will execute
  • rest_total_hits_as_int – Indicates whether hits.total should be rendered as an integer or an object in the rest search response
  • search_type – Search operation type
  • typed_keys – Specify whether aggregation and suggester names should be prefixed by their respective types in the response
mtermvectors(*, index: Optional[str] = None, docs: Union[List[Mapping[str, Any]], Tuple[Mapping[str, Any], ...], None] = None, error_trace: Optional[bool] = None, field_statistics: Optional[bool] = None, fields: Union[str, List[str], Tuple[str, ...], None] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, ids: Union[List[str], Tuple[str, ...], None] = None, offsets: Optional[bool] = None, payloads: Optional[bool] = None, positions: Optional[bool] = None, preference: Optional[str] = None, pretty: Optional[bool] = None, realtime: Optional[bool] = None, routing: Optional[str] = None, term_statistics: Optional[bool] = None, version: Optional[int] = None, version_type: Union[t.Literal['external', 'external_gte', 'force', 'internal'], str, None] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Returns multiple termvectors in one request.

https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-multi-termvectors.html

Parameters:
  • index – The index in which the document resides.
  • docs
  • 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”.
  • fields – A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body “params” or “docs”.
  • ids
  • offsets – Specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body “params” or “docs”.
  • payloads – Specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body “params” or “docs”.
  • positions – Specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body “params” or “docs”.
  • 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”.
  • realtime – Specifies if requests are real-time as opposed to near-real-time (default: true).
  • routing – Specific routing value. Applies to all returned documents unless otherwise specified in body “params” or “docs”.
  • 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”.
  • version – Explicit version number for concurrency control
  • version_type – Specific version type
open_point_in_time(*, index: Union[str, List[str], Tuple[str, ...]], keep_alive: Union[int, str], error_trace: Optional[bool] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, ignore_unavailable: Optional[bool] = None, pretty: Optional[bool] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Open a point in time that can be used in subsequent searches

https://www.elastic.co/guide/en/elasticsearch/reference/master/point-in-time-api.html

Parameters:
  • index – A comma-separated list of index names to open point in time; use _all or empty string to perform the operation on all indices
  • keep_alive – Specific the time to live for the point in time
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
ping(*, error_trace: Optional[bool] = None, filter_path: Union[List[str], str, None] = None, human: Optional[bool] = None, pretty: Optional[bool] = None) → bool

Returns True if a successful response returns from the info() API, otherwise returns False. This API call can fail either at the transport layer (due to connection errors or timeouts) or from a non-2XX HTTP response (due to authentication or authorization issues).

If you want to discover why the request failed you should use the info() API.

https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html

put_script(*, id: str, script: Mapping[str, Any], context: Optional[str] = None, error_trace: Optional[bool] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, master_timeout: Union[int, str, None] = None, pretty: Optional[bool] = None, timeout: Union[int, str, None] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Creates or updates a script.

https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html

Parameters:
  • id – Script ID
  • script
  • context – Script context
  • master_timeout – Specify timeout for connection to master
  • timeout – Explicit operation timeout
rank_eval(*, index: Union[str, List[str], Tuple[str, ...]], requests: Union[List[Mapping[str, Any]], Tuple[Mapping[str, Any], ...]], allow_no_indices: Optional[bool] = None, error_trace: Optional[bool] = None, expand_wildcards: Union[t.Literal['all', 'closed', 'hidden', 'none', 'open'], str, List[Union[t.Literal['all', 'closed', 'hidden', 'none', 'open'], str]], Tuple[Union[t.Literal['all', 'closed', 'hidden', 'none', 'open'], str], ...], None] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, ignore_unavailable: Optional[bool] = None, metric: Optional[Mapping[str, Any]] = None, pretty: Optional[bool] = None, search_type: Optional[str] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Allows to evaluate the quality of ranked search results over a set of typical search queries

https://www.elastic.co/guide/en/elasticsearch/reference/master/search-rank-eval.html

Parameters:
  • index – Comma-separated list of data streams, indices, and index aliases used to limit the request. Wildcard (*) expressions are supported. To target all data streams and indices in a cluster, omit this parameter or use _all or *.
  • requests – A set of typical search requests, together with their provided ratings.
  • allow_no_indices – If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. This behavior applies even if the request targets other open indices. For example, a request targeting foo*,bar* returns an error if an index starts with foo but no index starts with bar.
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both.
  • ignore_unavailable – If true, missing or closed indices are not included in the response.
  • metric – Definition of the evaluation metric to calculate.
  • search_type – Search operation type
reindex(*, dest: Mapping[str, Any], source: Mapping[str, Any], conflicts: Union[t.Literal['abort', 'proceed'], str, None] = None, error_trace: Optional[bool] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, max_docs: Optional[int] = None, pretty: Optional[bool] = None, refresh: Optional[bool] = None, requests_per_second: Optional[int] = None, require_alias: Optional[bool] = None, script: Optional[Mapping[str, Any]] = None, scroll: Union[int, str, None] = None, size: Optional[int] = None, slices: Union[int, t.Literal['auto'], str, None] = None, timeout: Union[int, str, None] = None, wait_for_active_shards: Union[int, t.Literal['all', 'index-setting'], str, None] = None, wait_for_completion: Optional[bool] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

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.

https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-reindex.html

Parameters:
  • dest
  • source
  • conflicts
  • max_docs
  • refresh – Should the affected indexes be refreshed?
  • requests_per_second – The throttle to set on this request in sub-requests per second. -1 means no throttle.
  • require_alias
  • script
  • scroll – Control how long to keep the search context alive
  • size
  • slices – The number of slices this task should be divided into. Defaults to 1, meaning the task isn’t sliced into subtasks. Can be set to auto.
  • timeout – Time each individual bulk request should wait for shards that are unavailable.
  • 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)
  • wait_for_completion – Should the request should block until the reindex is complete.
reindex_rethrottle(*, task_id: str, error_trace: Optional[bool] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, pretty: Optional[bool] = None, requests_per_second: Optional[int] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Changes the number of requests per second for a particular Reindex operation.

https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-reindex.html

Parameters:
  • task_id – The task id to rethrottle
  • requests_per_second – The throttle to set on this request in floating sub-requests per second. -1 means set no throttle.
render_search_template(*, id: Optional[str] = None, error_trace: Optional[bool] = None, file: Optional[str] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, params: Optional[Mapping[str, Any]] = None, pretty: Optional[bool] = None, source: Optional[str] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Allows to use the Mustache language to pre-render a search definition.

https://www.elastic.co/guide/en/elasticsearch/reference/master/render-search-template-api.html

Parameters:
  • id – The id of the stored search template
  • file
  • params
  • source
scripts_painless_execute(*, context: Optional[str] = None, context_setup: Optional[Mapping[str, Any]] = None, error_trace: Optional[bool] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, pretty: Optional[bool] = None, script: Optional[Mapping[str, Any]] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Allows an arbitrary script to be executed and a result to be returned

https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-execute-api.html

Parameters:
  • context
  • context_setup
  • script
scroll(*, scroll_id: str, error_trace: Optional[bool] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, pretty: Optional[bool] = None, rest_total_hits_as_int: Optional[bool] = None, scroll: Union[int, str, None] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Allows to retrieve a large numbers of results from a single search request.

https://www.elastic.co/guide/en/elasticsearch/reference/master/search-request-body.html#request-body-search-scroll

Parameters:
  • scroll_id – Scroll ID of the search.
  • rest_total_hits_as_int – If true, the API response’s hit.total property is returned as an integer. If false, the API response’s hit.total property is returned as an object.
  • scroll – Period to retain the search context for scrolling.
search(*, index: Union[str, List[str], Tuple[str, ...], None] = None, aggregations: Optional[Mapping[str, Mapping[str, Any]]] = None, aggs: Optional[Mapping[str, Mapping[str, Any]]] = None, allow_no_indices: Optional[bool] = None, allow_partial_search_results: Optional[bool] = None, analyze_wildcard: Optional[bool] = None, analyzer: Optional[str] = None, batched_reduce_size: Optional[int] = None, ccs_minimize_roundtrips: Optional[bool] = None, collapse: Optional[Mapping[str, Any]] = None, default_operator: Union[t.Literal['and', 'or'], str, None] = None, df: Optional[str] = None, docvalue_fields: Union[List[Mapping[str, Any]], Tuple[Mapping[str, Any], ...], None] = None, error_trace: Optional[bool] = None, expand_wildcards: Union[t.Literal['all', 'closed', 'hidden', 'none', 'open'], str, List[Union[t.Literal['all', 'closed', 'hidden', 'none', 'open'], str]], Tuple[Union[t.Literal['all', 'closed', 'hidden', 'none', 'open'], str], ...], None] = None, explain: Optional[bool] = None, fields: Union[List[Mapping[str, Any]], Tuple[Mapping[str, Any], ...], None] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, from_: Optional[int] = None, highlight: Optional[Mapping[str, Any]] = None, human: Optional[bool] = None, ignore_throttled: Optional[bool] = None, ignore_unavailable: Optional[bool] = None, indices_boost: Union[List[Mapping[str, float]], Tuple[Mapping[str, float], ...], None] = None, lenient: Optional[bool] = None, max_concurrent_shard_requests: Optional[int] = None, min_compatible_shard_node: Optional[str] = None, min_score: Optional[float] = None, pit: Optional[Mapping[str, Any]] = None, post_filter: Optional[Mapping[str, Any]] = None, pre_filter_shard_size: Optional[int] = None, preference: Optional[str] = None, pretty: Optional[bool] = None, profile: Optional[bool] = None, q: Optional[str] = None, query: Optional[Mapping[str, Any]] = None, request_cache: Optional[bool] = None, rescore: Union[Mapping[str, Any], List[Mapping[str, Any]], Tuple[Mapping[str, Any], ...], None] = None, rest_total_hits_as_int: Optional[bool] = None, routing: Optional[str] = None, runtime_mappings: Optional[Mapping[str, Union[Mapping[str, Any], List[Mapping[str, Any]], Tuple[Mapping[str, Any], ...]]]] = None, script_fields: Optional[Mapping[str, Mapping[str, Any]]] = None, scroll: Union[int, str, None] = None, search_after: Union[List[Union[None, float, int, str]], Tuple[Union[None, float, int, str], ...], None] = None, search_type: Union[t.Literal['dfs_query_then_fetch', 'query_then_fetch'], str, None] = None, seq_no_primary_term: Optional[bool] = None, size: Optional[int] = None, slice: Optional[Mapping[str, Any]] = None, sort: Union[str, Mapping[str, Any], List[Union[str, Mapping[str, Any]]], Tuple[Union[str, Mapping[str, Any]], ...], None] = None, source: Union[bool, Mapping[str, Any], None] = None, source_excludes: Union[str, List[str], Tuple[str, ...], None] = None, source_includes: Union[str, List[str], Tuple[str, ...], None] = None, stats: Union[List[str], Tuple[str, ...], None] = None, stored_fields: Union[str, List[str], Tuple[str, ...], None] = None, suggest: Optional[Mapping[str, Any]] = None, suggest_field: Optional[str] = None, suggest_mode: Union[t.Literal['always', 'missing', 'popular'], str, None] = None, suggest_size: Optional[int] = None, suggest_text: Optional[str] = None, terminate_after: Optional[int] = None, timeout: Optional[str] = None, track_scores: Optional[bool] = None, track_total_hits: Union[bool, int, None] = None, typed_keys: Optional[bool] = None, version: Optional[bool] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Returns results matching a query.

https://www.elastic.co/guide/en/elasticsearch/reference/master/search-search.html

Parameters:
  • index – A comma-separated list of index names to search; use _all or empty string to perform the operation on all indices
  • aggregations
  • aggs
  • 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)
  • allow_partial_search_results – Indicate if an error should be returned if there is a partial search failure or timeout
  • analyze_wildcard – Specify whether wildcard and prefix queries should be analyzed (default: false)
  • analyzer – The analyzer to use for the query string
  • 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.
  • ccs_minimize_roundtrips – Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution
  • collapse
  • default_operator – The default operator for query string query (AND or OR)
  • df – The field to use as default where no field prefix is given in the query string
  • docvalue_fields – Array of wildcard (*) patterns. The request returns doc values for field names matching these patterns in the hits.fields property of the response.
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both.
  • explain – If true, returns detailed information about score computation as part of a hit.
  • fields – Array of wildcard (*) patterns. The request returns values for field names matching these patterns in the hits.fields property of the response.
  • from – Starting document offset. By default, you cannot page through more than 10,000 hits using the from and size parameters. To page through more hits, use the search_after parameter.
  • highlight
  • ignore_throttled – Whether specified concrete, expanded or aliased indices should be ignored when throttled
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • indices_boost – Boosts the _score of documents from specified indices.
  • lenient – Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
  • 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
  • min_compatible_shard_node – The minimum compatible version that all shards involved in search should have for this request to be successful
  • min_score – Minimum _score for matching documents. Documents with a lower _score are not included in the search results.
  • pit – Limits the search to a point in time (PIT). If you provide a PIT, you cannot specify an <index> in the request path.
  • post_filter
  • 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 its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint.
  • preference – Specify the node or shard the operation should be performed on (default: random)
  • profile
  • q – Query in the Lucene query string syntax
  • query – Defines the search definition using the Query DSL.
  • request_cache – Specify if request cache should be used for this request or not, defaults to index level setting
  • rescore
  • rest_total_hits_as_int – Indicates whether hits.total should be rendered as an integer or an object in the rest search response
  • routing – A comma-separated list of specific routing values
  • runtime_mappings – Defines one or more runtime fields in the search request. These fields take precedence over mapped fields with the same name.
  • script_fields – Retrieve a script evaluation (based on different fields) for each hit.
  • scroll – Specify how long a consistent view of the index should be maintained for scrolled search
  • search_after
  • search_type – Search operation type
  • seq_no_primary_term – If true, returns sequence number and primary term of the last modification of each hit. See Optimistic concurrency control.
  • size – The number of hits to return. By default, you cannot page through more than 10,000 hits using the from and size parameters. To page through more hits, use the search_after parameter.
  • slice
  • sort
  • source – Indicates which source fields are returned for matching documents. These fields are returned in the hits._source property of the search response.
  • source_excludes – A list of fields to exclude from the returned _source field
  • source_includes – A list of fields to extract and return from the _source field
  • stats – Stats groups to associate with the search. Each group maintains a statistics aggregation for its associated searches. You can retrieve these stats using the indices stats API.
  • stored_fields – List of stored fields to return as part of a hit. If no fields are specified, no stored fields are included in the response. If this field is specified, the _source parameter defaults to false. You can pass _source: true to return both source fields and stored fields in the search response.
  • suggest
  • suggest_field – Specifies which field to use for suggestions.
  • suggest_mode – Specify suggest mode
  • suggest_size – How many suggestions to return in response
  • suggest_text – The source text for which the suggestions should be returned.
  • terminate_after – Maximum number of documents to collect for each shard. If a query reaches this limit, Elasticsearch terminates the query early. Elasticsearch collects documents before sorting. Defaults to 0, which does not terminate query execution early.
  • timeout – Specifies the period of time to wait for a response from each shard. If no response is received before the timeout expires, the request fails and returns an error. Defaults to no timeout.
  • track_scores – If true, calculate and return document scores, even if the scores are not used for sorting.
  • track_total_hits – Number of hits matching the query to count accurately. If true, the exact number of hits is returned at the cost of some performance. If false, the response does not include the total number of hits matching the query. Defaults to 10,000 hits.
  • typed_keys – Specify whether aggregation and suggester names should be prefixed by their respective types in the response
  • version – If true, returns document version as part of a hit.
search_mvt(*, index: Union[str, List[str], Tuple[str, ...]], field: str, zoom: int, x: int, y: int, aggs: Optional[Mapping[str, Mapping[str, Any]]] = None, error_trace: Optional[bool] = None, exact_bounds: Optional[bool] = None, extent: Optional[int] = None, fields: Union[str, List[str], Tuple[str, ...], None] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, grid_precision: Optional[int] = None, grid_type: Union[t.Literal['centroid', 'grid', 'point'], str, None] = None, human: Optional[bool] = None, pretty: Optional[bool] = None, query: Optional[Mapping[str, Any]] = None, runtime_mappings: Optional[Mapping[str, Union[Mapping[str, Any], List[Mapping[str, Any]], Tuple[Mapping[str, Any], ...]]]] = None, size: Optional[int] = None, sort: Union[str, Mapping[str, Any], List[Union[str, Mapping[str, Any]]], Tuple[Union[str, Mapping[str, Any]], ...], None] = None, track_total_hits: Union[bool, int, None] = None) → elastic_transport.BinaryApiResponse

Searches a vector tile for geospatial values. Returns results as a binary Mapbox vector tile.

https://www.elastic.co/guide/en/elasticsearch/reference/master/search-vector-tile-api.html

Parameters:
  • index – Comma-separated list of data streams, indices, or aliases to search
  • field – Field containing geospatial data to return
  • zoom – Zoom level for the vector tile to search
  • x – X coordinate for the vector tile to search
  • y – Y coordinate for the vector tile to search
  • aggs – Sub-aggregations for the geotile_grid. Supports the following aggregation types: - avg - cardinality - max - min - sum
  • exact_bounds – If false, the meta layer’s feature is the bounding box of the tile. If true, the meta layer’s feature is a bounding box resulting from a geo_bounds aggregation. The aggregation runs on <field> values that intersect the <zoom>/<x>/<y> tile with wrap_longitude set to false. The resulting bounding box may be larger than the vector tile.
  • extent – Size, in pixels, of a side of the tile. Vector tiles are square with equal sides.
  • fields – Fields to return in the hits layer. Supports wildcards (*). This parameter does not support fields with array values. Fields with array values may return inconsistent results.
  • grid_precision – Additional zoom levels available through the aggs layer. For example, if <zoom> is 7 and grid_precision is 8, you can zoom in up to level 15. Accepts 0-8. If 0, results don’t include the aggs layer.
  • grid_type – Determines the geometry type for features in the aggs layer. In the aggs layer, each feature represents a geotile_grid cell. If ‘grid’ each feature is a Polygon of the cells bounding box. If ‘point’ each feature is a Point that is the centroid of the cell.
  • query – Query DSL used to filter documents for the search.
  • runtime_mappings – Defines one or more runtime fields in the search request. These fields take precedence over mapped fields with the same name.
  • size – Maximum number of features to return in the hits layer. Accepts 0-10000. If 0, results don’t include the hits layer.
  • sort – Sorts features in the hits layer. By default, the API calculates a bounding box for each feature. It sorts features based on this box’s diagonal length, from longest to shortest.
  • track_total_hits – Number of hits matching the query to count accurately. If true, the exact number of hits is returned at the cost of some performance. If false, the response does not include the total number of hits matching the query.
search_shards(*, index: Union[str, List[str], Tuple[str, ...], None] = None, allow_no_indices: Optional[bool] = None, error_trace: Optional[bool] = None, expand_wildcards: Union[t.Literal['all', 'closed', 'hidden', 'none', 'open'], str, List[Union[t.Literal['all', 'closed', 'hidden', 'none', 'open'], str]], Tuple[Union[t.Literal['all', 'closed', 'hidden', 'none', 'open'], str], ...], None] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, ignore_unavailable: Optional[bool] = None, local: Optional[bool] = None, preference: Optional[str] = None, pretty: Optional[bool] = None, routing: Optional[str] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Returns information about the indices and shards that a search request would be executed against.

https://www.elastic.co/guide/en/elasticsearch/reference/master/search-shards.html

Parameters:
  • index – A comma-separated list of index names to search; use _all or empty string to perform the operation on all indices
  • 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)
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both.
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • local – Return local information, do not retrieve the state from master node (default: false)
  • preference – Specify the node or shard the operation should be performed on (default: random)
  • routing – Specific routing value
search_template(*, index: Union[str, List[str], Tuple[str, ...], None] = None, allow_no_indices: Optional[bool] = None, ccs_minimize_roundtrips: Optional[bool] = None, error_trace: Optional[bool] = None, expand_wildcards: Union[t.Literal['all', 'closed', 'hidden', 'none', 'open'], str, List[Union[t.Literal['all', 'closed', 'hidden', 'none', 'open'], str]], Tuple[Union[t.Literal['all', 'closed', 'hidden', 'none', 'open'], str], ...], None] = None, explain: Optional[bool] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, id: Optional[str] = None, ignore_throttled: Optional[bool] = None, ignore_unavailable: Optional[bool] = None, params: Optional[Mapping[str, Any]] = None, preference: Optional[str] = None, pretty: Optional[bool] = None, profile: Optional[bool] = None, rest_total_hits_as_int: Optional[bool] = None, routing: Optional[str] = None, scroll: Union[int, str, None] = None, search_type: Union[t.Literal['dfs_query_then_fetch', 'query_then_fetch'], str, None] = None, source: Optional[str] = None, typed_keys: Optional[bool] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Allows to use the Mustache language to pre-render a search definition.

https://www.elastic.co/guide/en/elasticsearch/reference/master/search-template.html

Parameters:
  • index – Comma-separated list of data streams, indices, and aliases to search. Supports wildcards (*).
  • 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)
  • ccs_minimize_roundtrips – Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both.
  • explain
  • id – ID of the search template to use. If no source is specified, this parameter is required.
  • ignore_throttled – Whether specified concrete, expanded or aliased indices should be ignored when throttled
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • params
  • preference – Specify the node or shard the operation should be performed on (default: random)
  • profile
  • rest_total_hits_as_int – If true, hits.total are rendered as an integer in the response.
  • routing – Custom value used to route operations to a specific shard.
  • scroll – Specifies how long a consistent view of the index should be maintained for scrolled search.
  • search_type – The type of the search operation.
  • source – An inline search template. Supports the same parameters as the search API’s request body. Also supports Mustache variables. If no id is specified, this parameter is required.
  • typed_keys – Specify whether aggregation and suggester names should be prefixed by their respective types in the response
terms_enum(*, index: str, field: str, case_insensitive: Optional[bool] = None, error_trace: Optional[bool] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, index_filter: Optional[Mapping[str, Any]] = None, pretty: Optional[bool] = None, search_after: Optional[str] = None, size: Optional[int] = None, string: Optional[str] = None, timeout: Union[int, str, None] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

The terms enum API can be used to discover terms in the index that begin with the provided string. It is designed for low-latency look-ups used in auto-complete scenarios.

https://www.elastic.co/guide/en/elasticsearch/reference/master/search-terms-enum.html

Parameters:
  • index – Comma-separated list of data streams, indices, and index aliases to search. Wildcard (*) expressions are supported.
  • field – The string to match at the start of indexed terms. If not provided, all terms in the field are considered.
  • case_insensitive – When true the provided search string is matched against index terms without case sensitivity.
  • index_filter – Allows to filter an index shard if the provided query rewrites to match_none.
  • search_after
  • size – How many matching terms to return.
  • string – The string after which terms in the index should be returned. Allows for a form of pagination if the last result from one request is passed as the search_after parameter for a subsequent request.
  • timeout – The maximum length of time to spend collecting results. Defaults to “1s” (one second). If the timeout is exceeded the complete flag set to false in the response and the results may be partial or empty.
termvectors(*, index: str, id: Optional[str] = None, doc: Optional[Mapping[str, Any]] = None, error_trace: Optional[bool] = None, field_statistics: Optional[bool] = None, fields: Union[str, List[str], Tuple[str, ...], None] = None, filter: Optional[Mapping[str, Any]] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, offsets: Optional[bool] = None, payloads: Optional[bool] = None, per_field_analyzer: Optional[Mapping[str, str]] = None, positions: Optional[bool] = None, preference: Optional[str] = None, pretty: Optional[bool] = None, realtime: Optional[bool] = None, routing: Optional[str] = None, term_statistics: Optional[bool] = None, version: Optional[int] = None, version_type: Union[t.Literal['external', 'external_gte', 'force', 'internal'], str, None] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Returns information and statistics about terms in the fields of a particular document.

https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-termvectors.html

Parameters:
  • index – The index in which the document resides.
  • id – The id of the document, when not specified a doc param should be supplied.
  • doc
  • field_statistics – Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned.
  • fields – A comma-separated list of fields to return.
  • filter
  • offsets – Specifies if term offsets should be returned.
  • payloads – Specifies if term payloads should be returned.
  • per_field_analyzer
  • positions – Specifies if term positions should be returned.
  • preference – Specify the node or shard the operation should be performed on (default: random).
  • realtime – Specifies if request is real-time as opposed to near-real-time (default: true).
  • routing – Specific routing value.
  • term_statistics – Specifies if total term frequency and document frequency should be returned.
  • version – Explicit version number for concurrency control
  • version_type – Specific version type
update(*, index: str, id: str, detect_noop: Optional[bool] = None, doc: Optional[Mapping[str, Any]] = None, doc_as_upsert: Optional[bool] = None, error_trace: Optional[bool] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, if_primary_term: Optional[int] = None, if_seq_no: Optional[int] = None, lang: Optional[str] = None, pretty: Optional[bool] = None, refresh: Union[t.Literal['false', 'true', 'wait_for'], bool, str, None] = None, require_alias: Optional[bool] = None, retry_on_conflict: Optional[int] = None, routing: Optional[str] = None, script: Optional[Mapping[str, Any]] = None, scripted_upsert: Optional[bool] = None, source: Union[bool, Mapping[str, Any], None] = None, source_excludes: Union[str, List[str], Tuple[str, ...], None] = None, source_includes: Union[str, List[str], Tuple[str, ...], None] = None, timeout: Union[int, str, None] = None, upsert: Optional[Mapping[str, Any]] = None, wait_for_active_shards: Union[int, t.Literal['all', 'index-setting'], str, None] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Updates a document with a script or partial document.

https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update.html

Parameters:
  • index – The name of the index
  • id – Document ID
  • detect_noop – Set to false to disable setting ‘result’ in the response to ‘noop’ if no change to the document occurred.
  • doc – A partial update to an existing document.
  • doc_as_upsert – Set to true to use the contents of ‘doc’ as the value of ‘upsert’
  • if_primary_term – Only perform the operation if the document has this primary term.
  • if_seq_no – Only perform the operation if the document has this sequence number.
  • lang – The script language.
  • refresh – If ‘true’, Elasticsearch refreshes 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’ do nothing with refreshes.
  • require_alias – If true, the destination must be an index alias.
  • retry_on_conflict – Specify how many times should the operation be retried when a conflict occurs.
  • routing – Custom value used to route operations to a specific shard.
  • script – Script to execute to update the document.
  • scripted_upsert – Set to true to execute the script whether or not the document exists.
  • source – Set to false to disable source retrieval. You can also specify a comma-separated list of the fields you want to retrieve.
  • source_excludes – Specify the source fields you want to exclude.
  • source_includes – Specify the source fields you want to retrieve.
  • timeout – Period to wait for dynamic mapping updates and active shards. This guarantees Elasticsearch waits for at least the timeout before failing. The actual wait time could be longer, particularly when multiple waits occur.
  • upsert – If the document does not already exist, the contents of ‘upsert’ are inserted as a new document. If the document exists, the ‘script’ is executed.
  • wait_for_active_shards – The number of shard copies that must be active before proceeding with the operations. Set to ‘all’ or any positive integer up to the total number of shards in the index (number_of_replicas+1). Defaults to 1 meaning the primary shard.
update_by_query(*, index: Union[str, List[str], Tuple[str, ...]], allow_no_indices: Optional[bool] = None, analyze_wildcard: Optional[bool] = None, analyzer: Optional[str] = None, conflicts: Union[t.Literal['abort', 'proceed'], str, None] = None, default_operator: Union[t.Literal['and', 'or'], str, None] = None, df: Optional[str] = None, error_trace: Optional[bool] = None, expand_wildcards: Union[t.Literal['all', 'closed', 'hidden', 'none', 'open'], str, List[Union[t.Literal['all', 'closed', 'hidden', 'none', 'open'], str]], Tuple[Union[t.Literal['all', 'closed', 'hidden', 'none', 'open'], str], ...], None] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, from_: Optional[int] = None, human: Optional[bool] = None, ignore_unavailable: Optional[bool] = None, lenient: Optional[bool] = None, max_docs: Optional[int] = None, pipeline: Optional[str] = None, preference: Optional[str] = None, pretty: Optional[bool] = None, query: Optional[Mapping[str, Any]] = None, refresh: Optional[bool] = None, request_cache: Optional[bool] = None, requests_per_second: Optional[int] = None, routing: Optional[str] = None, script: Optional[Mapping[str, Any]] = None, scroll: Union[int, str, None] = None, scroll_size: Optional[int] = None, search_timeout: Union[int, str, None] = None, search_type: Union[t.Literal['dfs_query_then_fetch', 'query_then_fetch'], str, None] = None, slice: Optional[Mapping[str, Any]] = None, slices: Union[int, t.Literal['auto'], str, None] = None, sort: Union[List[str], Tuple[str, ...], None] = None, stats: Union[List[str], Tuple[str, ...], None] = None, terminate_after: Optional[int] = None, timeout: Union[int, str, None] = None, version: Optional[bool] = None, version_type: Optional[bool] = None, wait_for_active_shards: Union[int, t.Literal['all', 'index-setting'], str, None] = None, wait_for_completion: Optional[bool] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Performs an update on every document in the index without changing the source, for example to pick up a mapping change.

https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update-by-query.html

Parameters:
  • index – A comma-separated list of index names to search; use _all or empty string to perform the operation on all indices
  • 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)
  • analyze_wildcard – Specify whether wildcard and prefix queries should be analyzed (default: false)
  • analyzer – The analyzer to use for the query string
  • conflicts
  • default_operator – The default operator for query string query (AND or OR)
  • df – The field to use as default where no field prefix is given in the query string
  • expand_wildcards – Whether to expand wildcard expression to concrete indices that are open, closed or both.
  • from – Starting offset (default: 0)
  • ignore_unavailable – Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • lenient – Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
  • max_docs
  • pipeline – Ingest pipeline to set on index requests made by this action. (default: none)
  • preference – Specify the node or shard the operation should be performed on (default: random)
  • query
  • refresh – Should the affected indexes be refreshed?
  • request_cache – Specify if request cache should be used for this request or not, defaults to index level setting
  • requests_per_second – The throttle to set on this request in sub-requests per second. -1 means no throttle.
  • routing – A comma-separated list of specific routing values
  • script
  • scroll – Specify how long a consistent view of the index should be maintained for scrolled search
  • scroll_size – Size on the scroll request powering the update by query
  • search_timeout – Explicit timeout for each search request. Defaults to no timeout.
  • search_type – Search operation type
  • slice
  • slices – The number of slices this task should be divided into. Defaults to 1, meaning the task isn’t sliced into subtasks. Can be set to auto.
  • sort – A comma-separated list of <field>:<direction> pairs
  • stats – Specific ‘tag’ of the request for logging and statistical purposes
  • terminate_after – The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
  • timeout – Time each individual bulk request should wait for shards that are unavailable.
  • version – Specify whether to return document version as part of a hit
  • version_type – Should the document increment the version number (internal) on hit or not (reindex)
  • 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)
  • wait_for_completion – Should the request should block until the update by query operation is complete.
update_by_query_rethrottle(*, task_id: str, error_trace: Optional[bool] = None, filter_path: Union[str, List[str], Tuple[str, ...], None] = None, human: Optional[bool] = None, pretty: Optional[bool] = None, requests_per_second: Optional[int] = None) → elastic_transport.ObjectApiResponse[typing.Any][Any]

Changes the number of requests per second for a particular Update By Query operation.

https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update-by-query.html

Parameters:
  • task_id – The task id to rethrottle
  • requests_per_second – The throttle to set on this request in floating sub-requests per second. -1 means set no throttle.