Summary
Every indexed type in ElasticGraph gets a __self update target that writes its own events to its own index. When a type is used purely as a source for sourced_from fields on another indexed type, this means its data is stored twice: once in its own index, and again in the destination type's index via the sourced-from update targets. For source types that are never queried on their own, the copy in their own index is pure overhead. This proposes an opt-in way to suppress a source type's __self write so its data flows only to its other update targets.
Proposed behavior
Add an opt-in flag (exact spelling TBD) that, when set on a source type, suppresses its __self update target: events of that type are no longer written to its own index, but the sourced_from update targets are still generated and applied, so the data continues to flow into the destination type(s)' indices exactly as before. Only the redundant standalone copy is dropped.
This is independent of whether the source type feeds top-level or nested sourced_from fields — in both cases the __self target is assembled separately from the sourced-from targets, so suppressing it leaves the sourcing flow intact.
Considerations
A couple of considerations when designing this:
- The type must not be queryable. If the type is exposed via root query fields, suppressing its own index would make those queries return nothing. This should be a schema-definition error.
- Source types carrying their own (non-sourced) data. If the type has fields that aren't flowed out to a destination, suppressing the self-write silently loses that data. This should be clear to end users.
Open questions
- Exact DSL surface (a flag on index, a separate DSL method, or a type-level setting).
- Whether to also omit the datastore index/mapping config for the suppressed type (no unused index created at all), or just suppress the writes while leaving the index in place.
Summary
Every indexed type in ElasticGraph gets a
__selfupdate target that writes its own events to its own index. When a type is used purely as a source forsourced_fromfields on another indexed type, this means its data is stored twice: once in its own index, and again in the destination type's index via the sourced-from update targets. For source types that are never queried on their own, the copy in their own index is pure overhead. This proposes an opt-in way to suppress a source type's__selfwrite so its data flows only to its other update targets.Proposed behavior
Add an opt-in flag (exact spelling TBD) that, when set on a source type, suppresses its
__selfupdate target: events of that type are no longer written to its own index, but thesourced_fromupdate targets are still generated and applied, so the data continues to flow into the destination type(s)' indices exactly as before. Only the redundant standalone copy is dropped.This is independent of whether the source type feeds top-level or nested
sourced_fromfields — in both cases the__selftarget is assembled separately from the sourced-from targets, so suppressing it leaves the sourcing flow intact.Considerations
A couple of considerations when designing this:
Open questions