Skip to content

Commit

Permalink
Fix README ident
Browse files Browse the repository at this point in the history
  • Loading branch information
fjsj committed Feb 12, 2019
1 parent 9d351f2 commit 1c1f6c8
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,60 +33,60 @@ Quickstart

1. Install ZomboDB (instructions `here <https://github.com/zombodb/zombodb/blob/master/INSTALL.md>`_)

::
::

pip install django-zombodb
pip install django-zombodb

2. Add the `SearchQuerySet` and the `ZomboDBIndex` to your model:

.. code-block:: python
.. code-block:: python
class Restaurant(models.Model):
name = models.TextField()
class Restaurant(models.Model):
name = models.TextField()
objects = models.Manager.from_queryset(SearchQuerySet)()
objects = models.Manager.from_queryset(SearchQuerySet)()
class Meta:
indexes = [
ZomboDBIndex(fields=(
'name',
)),
]
class Meta:
indexes = [
ZomboDBIndex(fields=(
'name',
)),
]
3. Make the migrations:

::
::

python manage.py makemigrations
python manage.py makemigrations

4. Add `django_zombodb.operations.ZomboDBExtension()` as the first operation of the migration you've just created:

.. code-block:: python
.. code-block:: python
import django_zombodb.operations
import django_zombodb.operations
class Migration(migrations.Migration):
class Migration(migrations.Migration):
dependencies = [
('restaurants', '0001_initial'),
]
dependencies = [
('restaurants', '0001_initial'),
]
operations = [
django_zombodb.operations.ZomboDBExtension(),
...
]
operations = [
django_zombodb.operations.ZomboDBExtension(),
...
]
5. Run the migrations (Postgres user must be SUPERUSER to create the ZomboDB extension):

::
::

python manage.py migrate
python manage.py migrate

6. Done! Now you can make Elasticsearch queries directly from your model:

.. code-block:: python
.. code-block:: python
Restaurant.objects.filter(is_open=True).query_string_search("brazil* AND coffee~")
Restaurant.objects.filter(is_open=True).query_string_search("brazil* AND coffee~")
Full Example
------------
Expand Down

0 comments on commit 1c1f6c8

Please sign in to comment.