When a document is recreated because the owning entity, or an entity it is part of of, is changed leading to all sorts of cascading database reads I often wonder: why? The reason is that the Index segments cannot be recreated for the indexed attributes. So we need to reinitialize the entity in order to recreate the Document.
But what if those attributes are actually @Stored in the original document and not dirty? Why not just read these values straight from the document with a single read in stead of executing a potentially great number of database reads?
This could be an optimization option available in @IndexedEmbedded(
optimize = Optimize.INDEXREAD
Optimize.INDEXREAD - assumes all relevant fields for this relation have store=Store.YES and can therefore be reread by reading the values from the document.
If any fields in the relation don't have Store.YES an error is thrown during initialization
If any fields in the relation is dirty, falls back to default (initialize entity).