Skip to content

Feature Suggestion - Get Indexed Document for Instance #1069

Open
@vanboom

Description

@vanboom

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 })

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions