You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c845040
Browse filesBrowse the repository at this point in the historyBrowse files
Support nested sourced_from fields end-to-end (#1252)
## Summary
Completes the nested `sourced_from` feature by wiring up the
indexing-time piece: the `update_index_data.painless` script now
resolves `sourced_from` fields onto nested elements of an indexed
document, not just top-level fields. This is the final PR in the nested
`sourced_from` series (building on the runtime-metadata,
relationship-chain, and update-target resolution PRs already merged to
main).
## What's included
- Painless script (`index_data.painless`) — nested-apply logic: buffers
each related event's sourced fields in `__nested_sourced_data` keyed by
a per-element key, then re-applies them onto the target nested element
on every event (so a later self-event that overwrites the nested array
doesn't drop sourced fields). Handles out-of-order ingestion, list and
object path segments, and multi-byte element ids via a length-prefixed
key encoding.
- One key keys both `__versions` and `__nested_sourced_data`; top-level
events keep a bare relationship key so existing documents stay
byte-identical and version-recovery is unchanged.
- Param threading — `update.rb` passes the registered nested-path config
(`sourcedFromNestedPaths`, `sourcedFromNestedPathIdentifiers`,
`sourcedFromNestedFields`) through to the script.
- `__nested_sourced_data` mapping — added to every index
(internal_fields), mirroring `__versions`.
- Test schema — `config/schema/teams.rb` gains a `Team →
staff.coaches[]/general_manager → *Profile` shape exercising nested
`sourced_from` over both list and singleton-object path segments, with
distinct source types.
- Tests — new `nested_multi_source_indexing_spec.rb` acceptance coverage
(out-of-order, root re-index, stale event, relationship-mutation
rejection, multi-byte ids, all-object + list paths); factories for the
new types; unit coverage for the threaded params and the
relationship-name guarantee the codec relies on.
## Deferred
- Schema-dump-time validation rejecting nested `sourced_from` on
list/__counts fields (not yet supported) — separate PR.
- Pruning of orphaned `__nested_sourced_data` entries and detection of
nested-element re-targeting — tracked as known limitations.
0 commit comments