django-elasticsearch-dsl is a Django application that wraps elasticsearch-dsl-py to provide an easy way to integrate Elasticsearch with Django models. It simplifies document definition, index management, and provides signal processors for automatic indexing of model changes. The current version is 9.0, and the project maintains an active release cadence with regular updates and support for new Django and Elasticsearch versions.
pip install django-elasticsearch-dslVerified import paths — ran on the pinned version, not inferred.
To get started, define your Elasticsearch settings in `settings.py`. Create a `Document` subclass for your Django model, register it with the `registry`, and define its fields using `elasticsearch_dsl.fields`. You can then rebuild your Elasticsearch index using the `search_index` management command and perform searches through the `Document`'s `.search()` method. Remember to configure a signal processor for real-time indexing.
Upgrade your Python environment to >=3.9 and Django to >=4.1 before upgrading django-elasticsearch-dsl to 8.0+. If using Elasticsearch, ensure compatibility with Elasticsearch 8.
Review your `DocType` definitions and convert them to `Document` subclasses. Ensure your Elasticsearch server is version 6.x or newer (and 7.x is recommended for `django-elasticsearch-dsl` 7.x).
Always ensure your `ELASTICSEARCH_DSL` dictionary in `settings.py` is correctly configured with at least a 'default' host. Use environment variables for sensitive data like hostnames or credentials.
Add `ELASTICSEARCH_DSL_SIGNAL_PROCESSOR` to your `settings.py` and choose an appropriate signal processor. For production, consider using an asynchronous processor like CelerySignalProcessor for better performance.