qpixel
qpixel copied to clipboard
Better searching - Elasticsearch support
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?)
- [x] ~~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