Skip to content
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

Better searching - Elasticsearch support #834

Draft
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

Taeir
Copy link
Contributor

@Taeir Taeir commented Aug 14, 2022

This PR adds (opt in) support for Elasticsearch.

To enable, the Global Site Setting ElasticsearchEnabled must be set to true.

Items left to do:

  • Update documentation on how to configure Elasticsearch (build index, resync/import data). (perhaps make rails tasks for that?)
  • Add support to other models/searches? (dropped, not necessary)
  • Add support for associated items? I.e. comments or answers.
  • Pass filters to Elasticsearch to improve search efficiency on large datasets (i.e. Codidact)
  • Boost posts based on score or upvotes, or negative boost posts with low score (?)

Some design questions:

  • Elasticsearch can be enabled and disabled without server restart. However, when enabling it, an Elasticsearch index resync is necessary to ensure that it is not out of sync with the database (otherwise you get error 500 pages for posts which were created while it was inactive, and searches will be working with outdated posts). In that sense, it does not need to support dynamic changing of the setting without restarts, and the code could perhaps be simplified (no mocking approach, just don't load ES at all if disabled).

See #833

Taeir added 6 commits August 14, 2022 23:22
Elasticsearch can be enabled and disabled site-wide. To prevent errors
when it is disabled (trying to update a model in the ES index), I've
used a mock here to not have to deal with the internal logic of ES
assigned callbacks.
Advantage is that it can be switched on and off while the site is
running. Only problem with that is that the ES DB must be resynced if
any changes were made while it was disabled, otherwise some actions will
cause error 500 since the update cannot be applied in the ES database.
@Taeir Taeir marked this pull request as draft August 14, 2022 21:38
Copy link
Member

@ArtOfCode- ArtOfCode- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good to me so far.

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

Successfully merging this pull request may close these issues.

2 participants