nick-boss-tech opened a new pull request, #5298: URL: https://github.com/apache/solr/pull/5298
🤖 *AI text below* 🤖 *(reviewed by Nick Shanin)* Jira: [SOLR-18608](https://issues.apache.org/jira/browse/SOLR-18608). This is the follow-up to SOLR-11364 (PR #5188), which fixed glob handling in the main search path; the two paths below were left on the pre-glob logic. The work was originally developed on top of the #5188 branch and has been ported onto its merged form. ## What happens today **Real-time get and the lazy-field prefetch ignore glob field selections.** Real-time get loads a document by the explicitly named fields only, so a selection like `fl=title,other_*` fetches the wrong stored set: fields the glob selects are not loaded the way the search path loads them, and fields that should stay lazy are loaded eagerly. The lazy prefetch in `SolrPluginUtils.optimizePreFetchDocs` keys off the explicit field names alone and does nothing at all when the selection is only a glob, so matching fields are never prefetched and highlighting over glob selections pays lazy loads per document. ## What this change does **Both paths now ask the document fetcher which stored fields a return-fields selection needs, the same computation the search path already uses.** [`SolrDocumentFetcher`](https://github.com/nick-boss-tech/solr/blob/7ee68a7000b67bed06ad3130ffff27a086a56aad/solr/core/src/java/org/apache/solr/search/SolrDocumentFetcher.java) exposes that computation as `getStoredFieldsToLoad(ReturnFields)`; it is the optimizer's existing logic, hoisted unchanged (a null result means all stored fields; otherwise the returned set is the mutable set to load). Real-time get loads through it and drops loaded fields the selection does not call for (`ReturnFields.loadsField`), so glob selections behave in `/get` exactly as in search. The prefetch now runs whenever the selection has explicit names or patterns, and prefetches the fetcher-computed set (plus highlight fields, as before). ## Proof **Four of the added tests fail on the base code with the defect's signatures and pass with this change; the surrounding suites stay green.** Recorded against unmodified `main` first: `testGlobRTGStoredFieldLoading` fails with "unrelated_s should remain lazy", `testGlobRTGEmptyAndAliasFieldLoading` with "title should remain lazy", `testGlobHighlightPrefetch` with "source_* did not prefetch source_s", and `testGlobPrefetchBoundaries` with a missing prefetched document for `fl=source_*`. With this change all pass. Five further added tests (highlight snippets and the pseudo-field/transformer glob cases) already passed on the base and are kept as coverage. Full gate at `7ee68a7000`: tidy clean, Error Prone compile passes, the five `BasicFunctionalityTest` glob tests pass, `TestPseudoReturnFields` passes 35 of 35, `ReturnFieldsTest` passes 16 of 16, and `:solr:core:check -x test` passes. ## Limits **The change is confined to field loading for real-time get and the lazy prefetch.** The stored-field computation itself is not altered; it is the same code the search path's optimizer already ran, now shared. Selections without globs take the same branches as before (the pre-existing `TestPseudoReturnFields` and `ReturnFieldsTest` suites pass unchanged), and document decoration, transformers, and highlighting logic are untouched apart from receiving the corrected field sets. *Nick Shanin directed the work and takes responsibility for this contribution.* -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
