[
https://issues.apache.org/jira/browse/SOLR-18625?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18145066#comment-18145066
]
ASF subversion and git services commented on SOLR-18625:
--------------------------------------------------------
Commit e22443ea8d56e3733bc9dfef85f15e2dec7f020b in solr's branch
refs/heads/main from Ian Springer
[ https://gitbox.apache.org/repos/asf?p=solr.git;h=e22443ea8d5 ]
SOLR-18625: eDisMax: don't emit empty pf or bq clauses (#5303)
Fix the eDisMax parser adding an empty phrase field (pf) boost clause when no
phrase qualifies for the boost, such as for single-term queries or q=*:*, and
an empty boost query (bq) clause when the bq consists only of stopwords. The
empty SHOULD clauses did not affect scoring but defeated the single-clause
MatchAllDocsQuery optimization; they are now omitted, so q=*:* reduces to a
MatchAllDocsQuery even when pf or bq is set.
Co-authored-by: Ian Springer <[email protected]>
Co-authored-by: Claude <[email protected]>
Co-authored-by: Nick Shanin <[email protected]>
Co-authored-by: Claude Fable 5.1 <[email protected]>
> eDisMax adds empty pf/bq clauses that defeat the MatchAllDocsQuery
> optimization
> -------------------------------------------------------------------------------
>
> Key: SOLR-18625
> URL: https://issues.apache.org/jira/browse/SOLR-18625
> Project: Solr
> Issue Type: Bug
> Components: query parsers
> Affects Versions: 9.9, 10.0
> Reporter: Ian Springer
> Priority: Minor
> Labels: pull-request-available
> Time Spent: 50m
> Remaining Estimate: 0h
>
> When {{pf}} is set and no phrase qualifies for the phrase boost, eDisMax adds
> an empty {{BooleanQuery}} to the main query as a {{SHOULD}} clause. This
> happens with single-term queries and with {{q=\*:\*}}. It shows up as {{()}}
> in the parsed query, e.g.:
> {noformat}
> defType=edismax&qf=subject&pf=subject&q=wireless
> -> +(subject:wireless) ()
> {noformat}
> Cause: in {{ExtendedDismaxQParser.addShingledPhraseQueries}}, the pf
> sub-parser runs with {{minClauseSize=2}}. That drops every one-position
> phrase, so {{pp.parse(...)}} returns an empty {{BooleanQuery}} instead of
> {{null}}. The {{phrase != null}} guard therefore lets it through.
> The same happens with {{bq}}: {{getBoostQueries}} adds each parsed boost
> query unchecked, and a {{bq}} consisting only of stopwords (e.g.
> {{bq=text:a}}) parses to an empty {{BooleanQuery}}.
> Impact:
> - Scoring is unaffected, because an empty SHOULD clause matches nothing.
> - It defeats the single-clause {{MatchAllDocsQuery}} unwrapping in
> {{ExtendedDismaxQParser.parse()}}. With {{pf}} or such a {{bq}} set,
> {{q=\*:\*}} therefore scores a {{BooleanQuery}} over every doc. It misses
> Solr's {{MatchAllDocsQuery}} fast paths (answered from the live-docs set,
> bypassing the filterCache).
> - Fielded-only queries such as {{q=subject:foo}} produce no pf clauses. They
> still create a sub-parser and analyze an empty phrase for each pf slop group.
> Fix:
> - Skip adding the phrase clause when the parsed result is empty, not just
> when it is null.
> - Return early from {{addShingledPhraseQueries}} when there are no clauses.
> - Skip boost queries that parse to an empty query.
> Ranking does not change. The pf part was originally in SOLR-18314 /
> https://github.com/apache/solr/pull/4652, which was closed because of its
> separate DisMax ranking change. Reviewers agreed that part was safe to merge
> on its own; the bq part is the same fix applied to the other path that can
> add an empty clause.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]