The official Python client for Elasticsearch.
- Translating basic Python data types to and from JSON
- Configurable automatic discovery of cluster nodes
- Persistent connections
- Load balancing (with pluggable selection strategy) across available nodes
- Failed connection penalization (time based - failed connections won't be retried until a timeout is reached)
- Support for TLS and HTTP authentication
- Thread safety across requests
- Pluggable architecture
- Helper functions for idiomatically using APIs together
Install the elasticsearch
package with pip:
$ python -m pip install elasticsearch
If your application uses async/await in Python you can install with
the async
extra:
$ python -m pip install elasticsearch[async]
Read more about how to use asyncio with this project.
Language clients are forward compatible; meaning that clients support communicating with greater or equal minor versions of Elasticsearch. Elasticsearch language clients are only backwards compatible with default distributions and without guarantees made.
If you have a need to have multiple versions installed at the same time older
versions are also released as elasticsearch2
and elasticsearch5
.
Documentation for the client is available on elastic.co and Read the Docs.
# Import the client from the 'elasticsearch' module
>>> from elasticsearch import Elasticsearch
# Instantiate a client instance
>>> client = Elasticsearch("http://localhost:9200")
# Call an API, in this example `info()`
>>> resp = client.info()
# View the result
>>> resp
{
"name" : "instance-name",
"cluster_name" : "cluster-name",
"cluster_uuid" : "cluster-uuid",
"version" : {
"number" : "7.14.0",
...
},
"tagline" : "You know, for Search"
}
You can read more about configuring the client in the documentation.
Copyright 2023 Elasticsearch B.V. Licensed under the Apache License, Version 2.0.