ispringer opened a new pull request, #5303:
URL: https://github.com/apache/solr/pull/5303

   https://issues.apache.org/jira/browse/SOLR-18625
   
   # Description
   
   When `pf` is set and no phrase qualifies for the boost (single-term queries, 
`q=*:*`), eDisMax's pf sub-parser discards every phrase via `minClauseSize` and 
returns an empty `BooleanQuery` rather than `null`. That passed the `phrase != 
null` guard and was added to the main query as an empty `SHOULD` clause 
(visible as `()` in the parsed query, e.g. `+(subject:wireless) ()`).
   
   It did not affect scoring, but it defeated the single-clause 
`MatchAllDocsQuery` unwrapping in `ExtendedDismaxQParser.parse()`, so `q=*:*` 
with `pf` set scored a `BooleanQuery` over every doc instead of reaching Solr's 
`MatchAllDocsQuery` fast paths.
   
   Split out from #4652 (closed), where this part was agreed to be safe on its 
own.
   
   # Solution
   
   In `addShingledPhraseQueries`:
   - Skip adding the phrase clause when the parsed result is empty, not only 
when it is null.
   - Return early when there are no clauses (e.g. fielded-only queries like 
`q=subject:foo`), avoiding creating a sub-parser and analyzing an empty phrase 
per pf slop group.
   
   No ranking change.
   
   Co-authored with Claude Code (Opus 5.5).
   
   # Tests
   
   New `TestExtendedDismaxParser.testNoEmptyPhraseBoostClause`:
   - `q=wireless` → no pf boost and no empty `()` clause (fails without the 
fix).
   - `q=wi-fi` (WordDelimiter splits into two tokens) → phrase boost retained.
   - `q=*:*` with `pf` → parses to `MatchAllDocsQuery`.
   
   Ran `TestExtendedDismaxParser`, `QueryEqualityTest`, 
`DisMaxRequestHandlerTest` (all green), plus `./gradlew tidy` and `./gradlew 
check -x test`.
   
   # Checklist
   
   - [x] I have reviewed the guidelines for [How to 
Contribute](https://github.com/apache/solr/blob/main/CONTRIBUTING.md) and my 
code conforms to the standards described there to the best of my ability.
   - [x] I have created a Jira issue and added the issue ID to my pull request 
title.
   - [x] I have given Solr maintainers 
[access](https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork)
 to contribute to my PR branch. (optional but recommended, not available for 
branches on forks living under an organisation)
   - [x] I have developed this patch against the `main` branch.
   - [x] I have run `./gradlew check`.
   - [x] I have added tests for my changes.
   - [ ] I have added documentation for the [Reference 
Guide](https://github.com/apache/solr/tree/main/solr/solr-ref-guide)
   - [x] I have added a [changelog 
entry](https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc) for my 
change
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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