[
https://issues.apache.org/jira/browse/SOLR-18625?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Ian Springer updated SOLR-18625:
--------------------------------
Description:
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.
was:
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.
Impact:
- Scoring is unaffected, because an empty SHOULD clause matches nothing.
- It defeats the single-clause {{MatchAllDocsQuery}} unwrapping in
{{ExtendedDismaxQParser.parse()}}. With {{pf}} 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.
Proposed 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.
Ranking does not change. This was originally part of SOLR-18314 /
https://github.com/apache/solr/pull/4652, which was closed because of its
separate DisMax ranking change. Reviewers agreed this part was safe to merge on
its own.
> 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: 10m
> 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]