Let us handle the boring stuff!
This extension provides a Elasticsearch client object configured via pyApp settings.
Install with pip:
pip install pyApp-elasticsearch-py
For AsyncIO support either:
pip install pyApp-elasticsearch-py[async]
# - OR -
pip install pyApp-elasticsearch-py aiohttp
Add the ELASTICSEARCH block into your runtime settings file:
ELASTICSEARCH = {
"default": {
"host": "localhost",
}
}
Note
In addition to the host any argument that can be provided to elasticsearch.Elasticsearch
or elasticsearch.AsyncElasticsearch
can be provided.
The following example creates an Elasticsearch client instance:
from pyapp_ext.elasticsearch import get_client
es = get_client()
Or an async Elasticsearch client instance:
from pyapp_ext.elasticsearch import get_async_client
es = get_async_client()