Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Lazy Document attributes
The idea is to define document attributes that can be lazy loaded and updated using update or bulk update operations. This is useful for example when a document has nested and denormalized fields that are expensive to update the whole document. So, you can retrieve the value of the attribute and partially update the document.
The lazy document attribute can be defined on the index repository level:
Note that the result of lazy_document_attribute is a hash where the key is one of the given post or its id.
So you to partially update the document by updating the comments count:
This could be part of some callback in the model or a background job.
You can also import documents by eager loading the lazy attribute or lazy loading it: