Skip to content

Search: remove django-elasticsearch-dsl dependency #10730

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
stsewd opened this issue Sep 13, 2023 · 2 comments
Open

Search: remove django-elasticsearch-dsl dependency #10730

stsewd opened this issue Sep 13, 2023 · 2 comments
Labels
Improvement Minor improvement to code

Comments

@stsewd
Copy link
Member

stsewd commented Sep 13, 2023

What's the problem this feature will solve?

django-elasticsearch-dsl is useful if you have an exact mapping with a model and one or several indexes in ES. But now that we are no longer tracking all HTML files in the DB, there is no need for that package, we also never made use of the signals feature, and we always have one index per model, and we are indexing just two types of documents, HTMLFile and Project.

Our code base could be simplified a lot if we just use https://elasticsearch-py.readthedocs.io/ directly (django-es-dsl is just an abstraction of that package). And we can also delete several fields from the HTMLFile/ImportedFile model that are just used for search.

Describe the solution you'd like

Just rely on the features that https://elasticsearch-py.readthedocs.io/ provides, which is really similar to what we have with django-es-dsl, since django-es-dsl mainly subclasses the other package to make it work with django models.

Alternative solutions

Keep using django-es-dsl and require ourselves to have a model with attributes we don't need per each document that we have in ES.

Additional context

@stsewd stsewd added the Improvement Minor improvement to code label Sep 13, 2023
stsewd added a commit that referenced this issue Sep 26, 2023
We need to wait for django-es/django-elasticsearch-dsl#458
or #10730.

There are no breaking changes in the API,
so this can be deployed without any downtime.

The only change is that it now has authentication enabled by default,
so our docker image now uses a password.

How to deploy:

- Deploy web extra
- The new packages will continue working with the old ES,
  but we can make sure by searching from web-extra.
- Finish the deploy
- Upgrade the ES cluster from cloud.elastic.co
stsewd added a commit that referenced this issue Oct 9, 2023
* Upgrade ES to 8.x

We need to wait for django-es/django-elasticsearch-dsl#458
or #10730.

There are no breaking changes in the API,
so this can be deployed without any downtime.

The only change is that it now has authentication enabled by default,
so our docker image now uses a password.

How to deploy:

- Deploy web extra
- The new packages will continue working with the old ES,
  but we can make sure by searching from web-extra.
- Finish the deploy
- Upgrade the ES cluster from cloud.elastic.co

* Forgot about this

* Fix tests

* Upgrade dependencies
@miguelgrinberg
Copy link

Hello from Elastic! I wanted to clarify something that may not be well understood.

The https://django-elasticsearch-dsl.readthedocs.io/ package is a wrapper around https://elasticsearch-dsl.readthedocs.io/, which Elastic maintains as an official high-level client.

You mention above that you would like to remove django-elasticsearch-dsl and go directly to https://elasticsearch-py.readthedocs.io/, which is the official low-level Elasticsearch client we maintain.

An alternative option that you have is to remove django-elasticsearch-dsl but keep using https://elasticsearch-dsl.readthedocs.io/. With this you would remove the association between Django models and Elasticsearch, but you can continue using a class-based approach to searching your Elasticsearch indexes.

If you have any question about the two official Elastic clients, please reach out!

@stsewd
Copy link
Member Author

stsewd commented May 20, 2024

@miguelgrinberg hi! thanks for the clarification. Yeah, we would just use elasticsearch-dsl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement Minor improvement to code
Projects
None yet
Development

No branches or pull requests

2 participants