django-elasticsearch-dsl | allows indexing of django models | Functional Testing library
kandi X-RAY | django-elasticsearch-dsl Summary
kandi X-RAY | django-elasticsearch-dsl Summary
This is a package that allows indexing of django models in elasticsearch with elasticsearch-dsl-py.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Delete a related object
- Yield related documents for the given instance
- Determine if we are enabled or not
- Setup the engine
- Autodiscover documentation
- Handle m2m changes
- Overrides save method
- Removes model instance from registry
django-elasticsearch-dsl Key Features
django-elasticsearch-dsl Examples and Code Snippets
Community Discussions
Trending Discussions on django-elasticsearch-dsl
QUESTION
to build and run a local instance, im following the tutorial at
https://haha.readthedocs.io/en/latest/install.html
but i use the git repo
https://github.com/readthedocs/readthedocs.org.git
instead of
https://github.com/rtfd/readthedocs.org.git
for the "git clone" command, as the link in the tutorial does not exist.
i am also using venv
, and not virtualenv
, as i was not able to make virtualenv
work.
i then get to the step to run the following command
...ANSWER
Answered 2022-Mar-31 at 07:21You are using python 3.10 which does not have a whl file available on PyPi for pywin32==227
. Try the installation with a lower python version e.g. 3.9
QUESTION
I am trying to call a local ES instance running on docker. I used the following instructions to setup my ES instance: https://www.elastic.co/guide/en/elasticsearch/reference/current/getting-started.html https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#docker-cli-run-dev-mode
I am able to play around with my instance on Kibana at http://0.0.0.0:5601/app/dev_tools#/console. Everything works upto here.
Now I am trying to define some sample documents using django models and index them through the library; I am following the instructions here: https://django-elasticsearch-dsl.readthedocs.io/en/latest/quickstart.html#install-and-configure
First, I add pip installed and added django_elasticsearch_dsl
to INSTALLED_APPS
Next, I added in settings.py:
...ANSWER
Answered 2022-Feb-28 at 09:47I figured that it was an issue with my certificate.
I needed to add some additional config param to the ELASTICSEARCH_DSL
variable. Adding this solves the issue:
QUESTION
I have a model that uses django hashid fields for the id
.
ANSWER
Answered 2021-Aug-21 at 02:56For anyone interested, I managed to solve this by overriding the generate_id
method of the Document
so that the _id
used is just a plain string:
QUESTION
I am using django-elasticsearch-dsl library a high level client to interact with elasticsearch.
This is my Document.py file
...ANSWER
Answered 2021-May-12 at 12:21I figured out how to explicitly map keyword fields:
In documents.py
QUESTION
I'm trying to implement the following Elasticsearch query using django-elasticsearch-dsl and am having some difficulty
Query
...ANSWER
Answered 2021-Feb-17 at 22:08As the author of elasticsearch-dsl-py
says, you'll need to use nested filters. One option would be:
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 am trying to build a simple django elastice search which can search cars. But when I am trying to rebuid the indexes, it gives me the error above. I am following this doc -> quickstart elasticsearch...full traceback is given below->
...ANSWER
Answered 2020-Oct-18 at 13:03First of all make sure you have installed and configured ElasticSearch service properly (you can use this document).This error is saying that your code could not connect to ElasticSearch
service with your current configs. Check if your elastic service is up and running. In Linux based OS you can check it by $ sudo systemctl status elasticsearch.service
and in the result page you should see the line Active: active (running)
. After this step check the url http://localhost:9200/
(if you did not change the default settings) and if everything is OK you should see the following results:
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
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install django-elasticsearch-dsl
You can use django-elasticsearch-dsl 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