nick-boss-tech opened a new pull request, #5133:
URL: https://github.com/apache/solr/pull/5133

   🤖 *AI text below* 🤖 *(posted on behalf of Nick Shanin)*
   
   https://issues.apache.org/jira/browse/SOLR-6759
   
   ## What happens today
   
   **The expand search never calls `complete()` on its post filter, so that 
filter's final step is skipped.**
   
   With `expand=true`, `ExpandComponent` runs a second search for the expanded 
groups. Unless `expand.fq` is given, that search reuses the query's filters, 
except collapse filters ([ExpandComponent.java lines 186-194 at the 
merge-base](https://github.com/nick-boss-tech/solr/blob/cabedd1d968059215188f4e7563fb303241899ed/solr/core/src/java/org/apache/solr/handler/component/ExpandComponent.java#L186-L194)).
 When one of those filters is a post filter, the search runs its collector 
chain. At the merge-base, the search is followed directly by the exit check, 
with no `complete()` call between them ([lines 441-448 at the 
merge-base](https://github.com/nick-boss-tech/solr/blob/cabedd1d968059215188f4e7563fb303241899ed/solr/core/src/java/org/apache/solr/handler/component/ExpandComponent.java#L441-L448)).
 A collapse filter given in `expand.fq` finishes its last segment in 
`complete()` ([CollapsingQParserPlugin.java lines 
794-827](https://github.com/nick-boss-tech/solr/blob/42f03eb5237658c29c5dac
 
bc5fc86b8ce48d8beb/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java#L794-L827)),
 so its last group can be missing from the expanded section.
   
   ## What this change does
   
   **The expand search now calls `complete()` on its collector chain after the 
search.**
   
   - The call runs only when the search has a post filter chain 
([ExpandComponent.java lines 
449-451](https://github.com/nick-boss-tech/solr/blob/42f03eb5237658c29c5dacbc5fc86b8ce48d8beb/solr/core/src/java/org/apache/solr/handler/component/ExpandComponent.java#L449-L451)).
 Without one, the code path is unchanged.
   - The main search already makes this call, inside a finally block 
([SolrIndexSearcher.java lines 
327-336](https://github.com/nick-boss-tech/solr/blob/42f03eb5237658c29c5dacbc5fc86b8ce48d8beb/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java#L327-L336)).
 The expand search now makes it too, without the finally block.
   
   ## Proof
   
   **A new test fails on the base code and passes with this change.**
   
   - `TestExpandComponent.testExpandCompletesPostFilterCollectors` ([test lines 
949-975](https://github.com/nick-boss-tech/solr/blob/42f03eb5237658c29c5dacbc5fc86b8ce48d8beb/solr/core/src/test/org/apache/solr/handler/component/TestExpandComponent.java#L949-L975))
 runs an expand query with a test-only post filter 
([CompleteTrackingQParserPlugin.java](https://github.com/nick-boss-tech/solr/blob/42f03eb5237658c29c5dacbc5fc86b8ce48d8beb/solr/core/src/test/org/apache/solr/handler/component/CompleteTrackingQParserPlugin.java)).
 The post filter counts the collectors it creates and the ones that get 
`complete()`. On the base code one collector is never completed.
   - Verified 2026-10-09 at head 42f03eb52376: TestExpandComponent 9 of 9. On 
the base code, with this test in place, the class runs 9 tests and one fails: 
this test.
   
   ## Limits
   
   **The test checks the `complete()` calls, not the expanded output.**
   
   - The test's post filter keeps every document. On the base code the failing 
check is the call count, not the expanded groups.
   - The test does not run a collapse filter through the expand search. The 
collapse case rests on reading the code.
   - The call sits after the search, not in a finally block. If the expand 
search ends with an exception, `complete()` is skipped. No test covers that 
path.
   
   Changelog: 
[changelog/unreleased/SOLR-6759-expand-complete-postfilter.yml](https://github.com/nick-boss-tech/solr/blob/42f03eb5237658c29c5dacbc5fc86b8ce48d8beb/changelog/unreleased/SOLR-6759-expand-complete-postfilter.yml)
   
   ### AI assistance
   
   AI agents assisted with research, implementation, review, and drafting. 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]

Reply via email to