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

Feature Suggestion - Get Indexed Document for Instance #1069

Open
vanboom opened this issue Jan 26, 2024 · 0 comments
Open

Feature Suggestion - Get Indexed Document for Instance #1069

vanboom opened this issue Jan 26, 2024 · 0 comments

Comments

@vanboom
Copy link

vanboom commented Jan 26, 2024

Suggestion: provide an instance method to allow fetching the indexed document if it exists.

Benefits:

  1. This would allow comparing the indexed instance with the Rails model attributes to allow for better index updating control. i.e. do not update the index if no attributes have changed. The update_document feature does not work for async indexing as the record is reloaded from the database unless the changes hash is passed to the async worker.
  2. This would allow integrity checking of the Rails SQL vs. the Elasticsearch for self-healing indexes if anything gets out of sync, e.g. if an async worker fails to update the index for whatever reason.

Thanks for your consideration. Is this a good idea? I will try to contribute a PR.

Maybe a simple get method on the Elasticsearch::Model::InstanceMethods?

client = YourModel.__elasticsearch__.client
document = client.get({ index: YourModel.index_name, id: id_to_find })
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

No branches or pull requests

1 participant