Lucene way search in django
("Django" AND "DRF") OR "Elasticserach-DSL"
Installation
Only for Django with DRF:
pip install lucyfer
For Django with DRF and Elasticsearch-dsl:
pip install lucyfer[full]
Dependencies
| lucyfer | lucyfer[full] | |
|---|---|---|
| lucyparser | + | + |
| Django | + | + |
| djangorestframework | + | + |
| elasticsearch-dsl | - | + |
Usage Example
Create your search backend class:
from lucyfer.backend import LuceneSearchFilter, DjangoLuceneSearchFilterMixin, ElasticLuceneSearchFilterMixin
class SearchBackend(DjangoLuceneSearchFilterMixin, ElasticLuceneSearchFilterMixin, LuceneSearchFilter):
pass
Copy reference to SearchBackend class and include it in DEFAULT_FILTER_BACKENDS in settings.py instead of default search backend:
REST_FRAMEWORK = {
'DEFAULT_FILTER_BACKENDS': ('path.to.SearchBackend',)
}
Create searchsets.py file in your django-application and fill it:
from lucyfer.searchset import DjangoSearchSet
from lucyfer.searchset.fields.django import DjangoCharField
from .models import MyModel
class MyModelSearchSet(DjangoSearchSet):
some_field = DjangoCharField(sources=["another_field__name"], exclude_sources_from_mapping=True)
class Meta:
model = MyModel
fields_to_exclude_from_mapping = ['field_to_exclude_from_mapping', ]
Include searchset class in your ModelViewSet:
from rest_framework.viewsets import ModelViewSet
from .searchsets import MyModelSearchSet
class MyModelViewSet(ModelViewSet):
search_class = MyModelSearchSet
You have to save search_fields in your ModelViewSet if you want to save custom search possibility.
Now you can use lucene-way syntax for your view.
Tests execution:
pytest tests/test_* -c tests/pytest.ini
Metadata
Release files for lucyfer 0.7.0
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 |
|---|---|---|---|---|
| lucyfer-0.7.0.tar.gz | 14.4 kB | Without provenance | Details for lucyfer-0.7.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lucyfer-0.7.0-py3-none-any.whl | Python 3 | none | any | Details for lucyfer-0.7.0-py3-none-any.whl |
Total release size: 36.4 kB
Release files / lucyfer-0.7.0.tar.gz
| Download URL | lucyfer-0.7.0.tar.gz |
|---|---|
| Size | 14.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9735ae0651ca39f04224a3c4eca1d1ccecb4e0db11ba9601a571736ba9c02175
|
|
BLAKE2b-256 checksum How to use checksums |
ad9f04659f7d056fbc03448611720bfb978ae59a6911f5e0ac72f6b6aa81eee2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.0
|
Release files / lucyfer-0.7.0-py3-none-any.whl
| Download URL | lucyfer-0.7.0-py3-none-any.whl |
|---|---|
| Size | 22.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d168736fd7a1777b1e0c6960bd15ff4475cee9cd45cd69593b32f756a83c348b
|
|
BLAKE2b-256 checksum How to use checksums |
da25be106cec11b35a4461d1287097fbf77e18e19ce5c0929dd3f9d64c1077d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.0
|
Security for lucyfer 0.7.0
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.