This is Django application that helps intergrate Django with elasticsearch. It is built on top of elasticsearch-dsl.
Project aims to support Python 3 and Django 1.8 (at least).
The library is in development, use it carefully, because until stable an API is a subject to change.
Quickstart
Configure your models to be indexable:
from django.db import models
from el.models import Indexed
class Article(models.Model, Indexed):
title = models.CharField(max_length=78)
@classmethod
def get_indexable(cls):
return cls.objects.all()
@classmethod
def configure_mapping(cls, mapping):
# mapping is an elasticsearch_dsl Mapping object
mapping.field('title', 'string')
return mapping
From this moment, the Article model will be autodiscovered and indexed.
Update search indexes:
./manage.py update_index
Use elasticsearch_dsl to query:
# articles is a list of an Article instances
articles = Article.search().query('match', title="Bob's article").execute()
# articles is a list of elasticsearch_dsl hits
articles = Article.search().query('match', title="Bob's article").execute(cast=False)
In contrast with elasticsearch_dsl, django-el provides modified Search object which return django model instances instead of raw elasticsearch results by default. You can control this feature using the cast argument.
Installation
Install django-el as usual python package using pip:
pip install django-el
Configuration
Django-el is build on top of elasticsearch_dsl library and provides django-way connections configuration through settings.py:
ELASTICSEARCH_CONNECTIONS = {
'default': {
'hosts': ['127.0.0.1:9200'],
'serializer': 'project.serializers.MySerializer',
}
}
You can define project connections using ELASTICSEARCH_CONNECTIONS setting. It is just a hight-level interface over low-level elasticsearch_dsl.connections.connections.create_connection function.
The keys are (default, in this example) are connection aliases, and it’s values are create_connection arguments.
Metadata
Release files for django-el 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-el-0.2.2.tar.gz | 7.0 kB | Without provenance | Details for django-el-0.2.2.tar.gz |
Release files / django-el-0.2.2.tar.gz
| Download URL | django-el-0.2.2.tar.gz |
|---|---|
| Size | 7.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
61fc64def31e53358d0fb45fb37b89bb2ef2ddbf76dd9c5eda1a881593549b01
|
|
BLAKE2b-256 checksum How to use checksums |
6a3fe89c2940412a2e56a2dfb4a59725efa64941f6da968cbfd7fc9f9db16078
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-el 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.