Elasticsearch: update_document irrelevant
Summary
We override update_document method. However in the normal circumstances it is bypassed, and ultimately triggers index_document instead.
This is because we trigger indexing asynchronously, but update_document would only do a proper update operation when the attribute changes are stored in the @__changed_model_attributes instance variable (this is setup by elasticsearch-rails' before_save callback).
Note indexing would still be done properly, because as passing the whole document to elasticsearch for indexing is perfectly valid.
We can either:
- Update its only caller
IndexRecordServiceto always callindex_documentinstead. - Pass changed attributes when asynchronously schedule indexing
Improvements
Remove unused code so is easier to understand.
Risks
N/A
Edited by 🤖 GitLab Bot 🤖