Easy Django integration with Elasticsearch through ZomboDB Postgres Extension
Easy Django integration with Elasticsearch through ZomboDB Postgres Extension. Thanks to ZomboDB, your Django models are synced with Elasticsearch after every transaction! Searching is also very simple: you can make Elasticsearch queries by just calling one of the search methods on your querysets. Couldn’t be easier!
The full documentation is at https://django-zombodb.readthedocs.io.
Python: 3.5, 3.6, 3.7
Django: 2.0, 2.1, 2.2
Postgres and Elasticsearch: same as ZomboDB current requirements
Install ZomboDB (instructions here)
pip install django-zombodb
Add the SearchQuerySet and the ZomboDBIndex to your model:
from django_zombodb.indexes import ZomboDBIndex from django_zombodb.querysets import SearchQuerySet class Restaurant(models.Model): name = models.TextField() objects = models.Manager.from_queryset(SearchQuerySet)() class Meta: indexes = [ ZomboDBIndex(fields=[ 'name', ]), ]
Make the migrations:
python manage.py makemigrations
Add django_zombodb.operations.ZomboDBExtension() as the first operation of the migration you’ve just created:
import django_zombodb.operations class Migration(migrations.Migration): dependencies = [ ('restaurants', '0001_initial'), ] operations = [ django_zombodb.operations.ZomboDBExtension(), # <<< here ]
Run the migrations (Postgres user must be SUPERUSER to create the ZomboDB extension):
python manage.py migrate
Done! Now you can make Elasticsearch queries directly from your model:
Restaurant.objects.filter(is_open=True).query_string_search("brazil* AND coffee~")
You need to have Elasticsearch and Postgres instances running on default ports. Also, you need ZomboDB installed. Then just do:
Please check SECURITY.rst. If you found or if you think you found a vulnerability please get in touch via admin AT vinta.com.br
Please avoid disclosing any security issue on GitHub or any other public website. We’ll work to swiftly address any possible vulnerability and give credit to reporters (if wanted).
Support for custom Elasticsearch mappings through field_mapping parameter on ZomboDBIndex.
Support to limit parameter on search methods.
Dropped support for Python 3.4.
Added missing imports to docs.
Removed parameter url from ZomboDBIndex. This simplifies the support of multiple deployment environments (local, staging, production), because the ElasticSearch URL isn’t copied to inside migrations code (see Issue #17).
First release on PyPI.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Hashes for django_zombodb-0.3.0-py2.py3-none-any.whl