Integrationsedit

You can find integration options and information on this page.

Transportedit

The handling of connections, retries, and pooling is handled by the Elastic Transport Python library. Documentation on the low-level classes is available on Read the Docs.

Tracking requests with Opaque IDedit

You can enrich your requests against Elasticsearch with an identifier string, that allows you to discover this identifier in deprecation logs, to support you with identifying search slow log origin or to help with identifying running tasks.

The opaque ID can be set via the opaque_id parameter via the client .options() method:

es = Elasticsearch(...)
es.options(opaque_id="request-id-...").search(...)

Type Hintsedit

Starting in elasticsearch-py v7.10.0 the library now ships with type hints and supports basic static type analysis with tools like Mypy and Pyright.

If we write a script that has a type error like using request_timeout with a str argument instead of float and then run Mypy on the script:

# script.py
from elasticsearch import Elasticsearch

es = Elasticsearch(...)
es.options(
    request_timeout="5"  # type error!
).search(...)

# $ mypy script.py
# script.py:5: error: Argument "request_timeout" to "search" of "Elasticsearch" has
#                     incompatible type "str"; expected "Union[int, float, None]"
# Found 1 error in 1 file (checked 1 source file)

Type hints also allow tools like your IDE to check types and provide better auto-complete functionality.