Skip to main content

Integrate Elasticsearch DSL with Django REST framework.

Project description

Integrate django-elasticsearch-dsl with Django REST framework in the shortest way possible, with least efforts possible.

Package provides views, filter backends and other handy tools.

You are expected to use django-elasticsearch-dsl for defining your document models.

Prerequisites

  • Django 1.8, 1.9, 1.10 and 1.11.

  • Python 2.7, 3.4, 3.5, 3.6

  • Elasticsearch 2.x, 5.x

Dependencies

  • django-elasticsearch-dsl

  • djangorestframework

Installation

  1. 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
  2. Add rest_framework and django_elasticsearch_dsl to INSTALLED_APPS:

    INSTALLED_APPS = (
        # ...
        'rest_framework',  # REST framework
        'django_elasticsearch_dsl',  # Elasticsearch integration
        # ...
    )

Filtering

Supported lookups

Native

The following native (to Elasticsearch) filters/lookups are implemented:

term

terms

range

exists

prefix

wildcard

ids

Functional

The following functional (non-native to Elasticsearch, but common in Django) filters/lookups are implemented:

contains

in

gt

gte

lt

lte

startswith

endswith

isnull

exclude

Usage examples

See the example project for sample models/views/serializers.

Additionally, see:

Testing

Project is covered with tests.

To test with all supported Python/Django versions type:

tox

To test against specific environment, type:

tox -e py36-django110

To test just your working environment type:

./runtests.py

To run a single test in your working environment type:

./runtests.py src/django_elasticsearch_dsl_drf/tests/test_filtering.py

Or:

./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

Writing documentation

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
**************************

License

GPL 2.0/LGPL 2.1

Support

For any issues contact me at the e-mail given in the Author section.

Author

Artur Barseghyan <artur.barseghyan@gmail.com>

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-elasticsearch-dsl-drf-0.1.6.tar.gz (35.0 kB view hashes)

Uploaded Source

Built Distribution

django_elasticsearch_dsl_drf-0.1.6-py2.py3-none-any.whl (27.9 kB view hashes)

Uploaded Python 2 Python 3

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