django-elasticsearch-dsl-drf | Integrate Elasticsearch DSL with Django REST framework | REST library
kandi X-RAY | django-elasticsearch-dsl-drf Summary
kandi X-RAY | django-elasticsearch-dsl-drf Summary
Integrate Elasticsearch DSL with Django REST framework.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Filter queryset
- Apply prefix filter to queryset
- Apply a range filter
- Gets the range parameters for the given value
- Constructs a search query
- Splits a LookupMultiple value into multiple values
- Splits a LookupLookup_name
- Filters the queryset using the given filters
- Applies suggester completions to the queryset
- Filters the queryset
- Provide country indexing
- Returns a list of field fields for view
- Return the schema fields for a view
- Get a single page of objects
- Returns a single page of objects
- Return a list of schema fields for view
- Return galaxy index
- Deprecated
- Construct a search query
- Return a single object
- Return the most like - like object
- Filter the queryset
- Paginate a queryset
- Build filter query query params
- Returns a dictionary that maps a city index to a dictionary
- Parse geo distance parameters
django-elasticsearch-dsl-drf Key Features
django-elasticsearch-dsl-drf Examples and Code Snippets
Community Discussions
Trending Discussions on django-elasticsearch-dsl-drf
QUESTION
I am trying to implement search suggestions using django-elasticsearch-dsl-drf
for streets.
This is documents.py
:
ANSWER
Answered 2020-Nov-22 at 22:08It looks like you're using wrong endpoint for suggestions. Correct name is suggest
.
Example: http://127.0.0.1:8000/search/publishers/suggest/?country_suggest__completion=Ar
As of your question about using two fields for suggestion at once, it's possible to get suggestions for multiple fields at once. For instance, if you have title
and author
, both properly indexed and configured, you could query it as follows:
http://127.0.0.1:8000/search/books/suggest/?title_suggest=wa&author_suggest=le
This will, however, return you the following result:
QUESTION
How to make OR query (using django-elasticsearch-dsl-drf) with multiple contains statements? Query in words: Search for objects where title contains "hello" OR description contains "world"
I can't find about it in documentation: https://django-elasticsearch-dsl-drf.readthedocs.io/en/0.3.12/advanced_usage_examples.html#usage-example
...ANSWER
Answered 2020-Oct-26 at 09:53what you need is boolean query with should clause, its very easy to construct in JSON format, and validate the search results.
For Django, although I am not familiar, this page of queries DSL and specifically this sub-section should fix your issue.
QUESTION
I used two packages (i.e. django-elasticsearch-dsl==7.1.4
and django-elasticsearch-dsl-drf==0.20.8
) to add a search engine to my Django project.
The model which I indexed in elastic is:
ANSWER
Answered 2020-Sep-22 at 12:45The problem was in my suggester configurations. First of all for term
and phrase
suggest we do not need completion fields (i.e. 'suggest': fields.CompletionField()
) and we just need to declare our field in our Index
, something like:
QUESTION
I’m building a Django web application to store documents and their associated metadata.
The bulk of the metadata will be stored in the underlying MySQL database, with the OCR’d document text indexed in Elasticsearch to enable full-text search. I’ve incorporated django-elasticsearch-dsl to connect and synchronize my data models, as I’m also indexing (and thus, double-storing) a few other fields found in my models. I had considered using Haystack, but it lacks support for the latest Elasticsearch versions.
When a document is uploaded via the applications’s admin interface, a post_save signal automatically triggers a Celery asynchronous background task to perform the OCR and will ultimately index the extracted text into Elasticsearch.
Seeing as how I don’t have a full-text field defined in my model (and hope to avoid doing so as I don’t want to store or search against CLOB’s in the database), I’m seeking the best practice for updating my Elasticsearch documents from my tasks.py file. There doesn’t seem to be a way to do so using django-elasticseach-dsl (but maybe I’m wrong?) and so I’m wondering if I should either:
Try to interface with Elasticsearch via REST using the sister django-elasticsearch-dsl-drf package.
More loosely integrate my application with Elasticsearch by using the more vanilla elasticsearch-dsl-py package (based on elasticsearch-py). I‘d lose some “luxury” with this approach as I’d have to write a bit more integration code, at least if I want to wire up my models with signals.
Is there a best practice? Or another approach I haven’t considered?
Update 1: In trying to implement the answer from @Nielk, I'm able to persist the OCR'd text (result = "test" in tasks.py below) into ElasticSearch, but it's also persisting in the MySQL database. I'm still confused about how to essentially configure Submission.rawtext as a passthru to ElasticSearch.
models.py:
...ANSWER
Answered 2020-Apr-21 at 06:06You can add extra fields in the document definition linked to your model (see the field 'type_to_field' in the documentation https://django-elasticsearch-dsl.readthedocs.io/en/latest/fields.html#using-different-attributes-for-model-fields , and combine this with a 'prepare_xxx' method to initialize to an empty string if the instance is created, and to its current value in case of an update) Would that solve your problem ?
Edit 1 - Here's what I meant:
models.py
QUESTION
The situation I'm currently trying to solve is a case where GeoSpatialOrderingFilterBackend is used from ElasticSearch DSL - DRF
, which orders the documents based on a location (lat, long), this in return gives out a elasticsearch_dsl.search.Search
queryset - ordered as it should; although I have a case where some are featured
and therefore would like to move them to the top of the queryset.
Scenario (as is):
...ANSWER
Answered 2020-Feb-13 at 11:20GeoSpatialOrderingFilterBackend
provides the ordering query params within the get_ordering_query_params
function. When you are ordering again based on featured
, consider also those parameters in your query.
QUESTION
On my MacBook (version 10.14.6) I am succesfully running a Django application including TensorFlow and tf-sentencepiece (in particular to use the universal sentence encoder model). When I perform a pipenv lock -r > requirements.txt
I get the following required packages:
ANSWER
Answered 2020-Jan-09 at 09:54I have no skills in Django, but it seems that tensorflow is trying to find a package (with a strange name) and failing.
I'd first suggest to try and fix your docker container setup, and check that pipenv lock -r
yield the same result inside and outside your container.
1) as you said in the commentaries, on the host pc
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install django-elasticsearch-dsl-drf
You can use django-elasticsearch-dsl-drf like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page