Easy Django integration with Elasticsearch through ZomboDB Postgres Extension
Project description
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!
Documentation
The full documentation is at https://django-zombodb.readthedocs.io.
Quickstart
Install ZomboDB (instructions here)
Install django-zombodb:
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~")
Full Example
Check https://github.com/vintasoftware/django-zombodb/tree/master/example
Running Tests
You need to have Elasticsearch and Postgres instances running on default ports. Then just do:
python runtests.py
Change Log
0.1.0 (2019-02-01)
First release on PyPI.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-zombodb-0.1.2.tar.gz
.
File metadata
- Download URL: django-zombodb-0.1.2.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/3.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fb2cbc9dd7f9546432f8fe425fd2e2bf2c57bb28dfe164607a21331da511582 |
|
MD5 | 95922b806cf80db2810a2cce10e7333a |
|
BLAKE2b-256 | 98df7691145b75b0f74f235a805959cbae51373abdbc98acad898f16912dcbbd |
Provenance
File details
Details for the file django_zombodb-0.1.2-py2.py3-none-any.whl
.
File metadata
- Download URL: django_zombodb-0.1.2-py2.py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/3.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 129577d6574a95288c74d85910a1b40c70e2e634c4224e213cdc7e707f7dc52b |
|
MD5 | 60b7c22340d86fb8803d937aa3d59342 |
|
BLAKE2b-256 | 300d441402798d9f025266a19b59701cbec7351c9fbd0b41ab41139d21d0c647 |