Django Haystack ES
Django Haystack backend for Elasticsearch 5.
Quickstart
Install Django Haystack ES:
pip install django-haystack-es
Add haystack_es.backends.ElasticsearchSearchEngine to your HAYSTACK_CONNECTIONS engine in settings.py
Example
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack_es.backends.Elasticsearch5SearchEngine',
# ...
}
}
Define your indexes using haystack_es.indexes instead of haystack.indexes.
Example
# myapp/search_indexes.py
from haystack_es import indexes
from myapp.models import MyModel
class MyModelIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
# ...
If you have celery-haystack installed you can use haystack_es.indexes.CelerySearchIndex for defining your SearchIndex utilizing celery-haystack
If you want to utilize additional SearchQuerySet methods use haystack_es.query.SearchQuerySet instead of haystack.query.SearchQuerySet.
Example
from haystack_es.query import SearchQuerySet
sqs = SearchQuerySet().filter(content='some query')
sqs.boost_fields({'field_name': 2, 'some_field': 1.5, 'another_field': 1})
sqs.facet('some_field')
# ...
Differences compared to the default django-haystack Elasticsearch backend
Intended for Elasticsearch >= 5
Allows query-time fields boosting.
Allows query-time negative boost
Provides additional SearchFields; DictField, NestedField and GeometryField
Tries to use Elasticsearch filter context instead of query string for filtering results.
Uses multi-fields for creating shadow fields which are useful for performing operations like faceting and exact matches which need non-analyzed values.
Query-time fields boosting
from haystack_es.query import SearchQuerySet SearchQuerySet().boost_fields(boost_fields)
Example SearchQuerySet().boost_fields({'field_name': 2, 'another_field': 1})
Negative boosting
from haystack_es.query import SearchQuerySet SearchQuerySet().boost_negative(query, negative_boost)
example SearchQuerySet().boost_negative({'match': {'category.raw': 'awful type'}}, negative_boost)
Running Tests
Does the code actually work?
source <YOURVIRTUALENV>/bin/activate (myenv) $ pip install tox (myenv) $ tox
Credits
Inspired by
haystack-elasticsearch5: https://github.com/Alkalit/haystack-elasticsearch5
Tools used in rendering this package:
History
0.1.0 (2017-07-27)
First release on PyPI.
0.2.8 (2019-07-18)
Simplify Django Version in Tox.
Metadata
Release files for django-haystack-es 0.2.8
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-haystack-es-0.2.8.tar.gz | 14.9 kB | Without provenance | Details for django-haystack-es-0.2.8.tar.gz |
Release files / django-haystack-es-0.2.8.tar.gz
| Download URL | django-haystack-es-0.2.8.tar.gz |
|---|---|
| Size | 14.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d4baa240d45da8a0d90031ba8807530c804b74c9026a70aa064378632301be85
|
|
BLAKE2b-256 checksum How to use checksums |
2d7d4bd6e9e5db1a75c2b5ae7cf7fa64406e93a39d7875279dc0dc4c1406910f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.7
|
Security for django-haystack-es 0.2.8
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.