Skip to main content

Easy Django integration with Elasticsearch through ZomboDB Postgres Extension

Project description

PyPI Status Build Status Documentation Status Coverage Status

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

  1. Install ZomboDB (instructions here)

  2. Install django-zombodb:

pip install django-zombodb
  1. 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',
            ]),
        ]
  1. Make the migrations:

python manage.py makemigrations
  1. 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
    ]
  1. Run the migrations (Postgres user must be SUPERUSER to create the ZomboDB extension):

python manage.py migrate
  1. 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

django-zombodb-0.1.0.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

django_zombodb-0.1.0-py2.py3-none-any.whl (11.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django-zombodb-0.1.0.tar.gz.

File metadata

  • Download URL: django-zombodb-0.1.0.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.7

File hashes

Hashes for django-zombodb-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9bae573565a2beb2f589815d9fc06debe2d0cd81f844b6bd9934d935b1df13bd
MD5 f82c2ccd0e2a184efdc6e3828988c215
BLAKE2b-256 a5fd05b34479358b4fe4dc21db8a0d6cadef8b5d98aa232f6b0e4f72bd7e1642

See more details on using hashes here.

Provenance

File details

Details for the file django_zombodb-0.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_zombodb-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 70c029109cdca3fcbaab47b42acccb1456568682e0a8d73e3420c46d10614ee5
MD5 ac4688edaf073fecad09caf915972dc6
BLAKE2b-256 0221c4f1d7429055cdaadaf963db3cd6fa42111a7a5664e44a20bc0b2bbe9b59

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page