Package provides views, serializers, filter backends and other handy tools.
You are expected to use django-elasticsearch-dsl for defining your document models.
Install latest stable version from PyPI:
pip install django-elasticsearch-dsl-drf
or latest stable version from GitHub:
pip install https://github.com/barseghyanartur/django-elasticsearch-dsl-drf/archive/stable.tar.gz
INSTALLED_APPS = ( # ... # REST framework 'rest_framework', # Django Elasticsearch integration 'django_elasticsearch_dsl', # Django REST framework Elasticsearch integration (this package) 'django_elasticsearch_dsl_drf', # ... )
Perhaps the easiest way to get acquainted with
is to read the quick start tutorial.
See it as a guide of diving into integration of Elasticsearch with Django with very low knowledge entry level.
Query param name reserved for search is
search. Make sure your models and
documents do not have it as a field or attribute.
Multiple search terms are joined with
Let’s assume we have a number of Book items with fields
Search in all fields (
country) for word “reilly”.
In order to search in specific field (
name) for term “reilly”, add
the field name separated with
| to the search term.
In order to search for multiple terms “reilly”, “bloomsbury” add
search query params.
The following native (to Elasticsearch) filters/lookups are implemented:
Find documents which contain the exact term specified in the field specified.
Find documents where the field specified contains values (dates, numbers, or strings) in the range specified.
Find documents where the field specified contains terms which begin with the exact prefix specified.
Find documents where the field specified contains terms which match the pattern specified, where the pattern supports single character wildcards (?) and multi-character wildcards (*)
The following functional (non-native to Elasticsearch, but common in Django) filters/lookups are implemented:
See the example project for sample models/views/serializers.
Project is covered with tests.
To test with all supported Python/Django versions type:
To test against specific environment, type:
tox -e py36-django110
To test just your working environment type:
To run a single test in your working environment type:
./manage.py test django_elasticsearch_dsl_drf.tests.test_ordering
It’s assumed that you have all the requirements installed. If not, first install the test requirements:
pip install -r examples/requirements/test.txt
Keep the following hierarchy.
===== title ===== header ====== sub-header ---------- sub-sub-header ~~~~~~~~~~~~~~ sub-sub-sub-header ^^^^^^^^^^^^^^^^^^ sub-sub-sub-sub-header ++++++++++++++++++++++ sub-sub-sub-sub-sub-header **************************
Table of Contents
- Quick start
- Usage examples
- Writing documentation
- Indices and tables
- django_elasticsearch_dsl_drf package
- django_elasticsearch_dsl_drf.filter_backends package
- django_elasticsearch_dsl_drf.apps module
- django_elasticsearch_dsl_drf.constants module
- django_elasticsearch_dsl_drf.helpers module
- django_elasticsearch_dsl_drf.views module
- Module contents
- Quick start
- Example app
- Sample models
- Admin classes
- Create database tables
- Fill in some data
- Sample document
- Syncing Django’s database with Elasticsearch indexes
- Sample serializer
- ViewSet definition
- Check what you’ve done so far
- Development and debugging
- Basic Django REST framework integration example
- Advanced Django REST framework integration example
- Various handy helpers