Allow FetchSubPhaseProcessors to report their required stored fields …#1
Open
MitchLewis930 wants to merge 1 commit intopr_011_beforefrom
Open
Allow FetchSubPhaseProcessors to report their required stored fields …#1MitchLewis930 wants to merge 1 commit intopr_011_beforefrom
MitchLewis930 wants to merge 1 commit intopr_011_beforefrom
Conversation
…lastic#91269) Loading of stored fields is currently handled directly in FetchPhase, with some fairly complex logic examining various bits of the FetchContext to work out what fields need to be loaded. This is further complicated by synthetic source, which may have its own stored field requirements. This commit tries to separate out these concerns a little by adding a new StoredFieldsSpec record that holds information about which stored fields need to be loaded. Each FetchSubPhaseProcessor can now report a StoredFieldsSpec detailing what its requirements are, and these specs can be merged together, along with requirements from a SourceLoader, to determine up-front what fields should be loaded by the StoredFieldLoader. The stored fields themselves are added into the SearchHit by a new StoredFieldsPhase, which handles alias resolution and value post- processing. The logic to determine when source should be loaded and when not, based on the presence of script fields or stored fields, is moved into FetchContext, which highlights some inconsistencies that can be fixed in follow-up commits.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| } | ||
|
|
||
| if (fieldType.isStored()) { | ||
| storedFields.add(fieldType.name()); |
There was a problem hiding this comment.
Unused variable storedFields populated but never read
Low Severity
The storedFields set is created and populated in the loop (adding field names when fieldType.isStored() is true), but it's never actually used. The TODO comment on lines 164-166 acknowledges this, stating the stored fields will be used "in future" but are currently "loaded separately in HighlightUtils." This dead code adds unnecessary computation and can confuse future developers about the intended data flow.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.


PR_011
Note
Medium Risk
Touches core search fetch execution and stored field/source loading decisions, which can affect response contents and performance; changes are broad but largely mechanical with test updates.
Overview
Refactors the search fetch phase so each
FetchSubPhaseProcessorreports what it needs via a newstoredFieldsSpec()API, andFetchPhasemerges these requirements to decide whether to load_sourceand which stored fields to load.Introduces a dedicated
StoredFieldsPhase(registered inSearchModule) that turns loaded stored fields into hitfields/metadata, updatesFetchSubPhase.HitContextto carry the raw loaded fields, and simplifiesSearchHitfield storage/constructors accordingly; tests/docs are updated and REST/YAML compatibility tests are skipped/adjusted due to the newStoredFieldsPhaseshowing up in fetch profiling output.Written by Cursor Bugbot for commit 547c832. This will update automatically on new commits. Configure here.