Ian Springer created SOLR-18314:
-----------------------------------
Summary: skip phrase field (pf) boost analysis for single-term
queries since a one-word phrase is semantically meaningless and wastes CPU
Key: SOLR-18314
URL: https://issues.apache.org/jira/browse/SOLR-18314
Project: Solr
Issue Type: Improvement
Components: query parsers
Reporter: Ian Springer
When a query contains only a single term, the phrase fields (`pf`) parameter
still triggers full phrase analysis — constructing a query string,
instantiating a query parser, parsing, and only then discarding the result
because `minClauseSize=2` rejects single-term phrases. For `pf2`/`pf3` this was
already short-circuited (the shingle size check catches it), but `pf` with
`shingleSize=0` bypassed that guard and did all the work before throwing it
away. The same issue exists in classic DisMax where `getPhraseQuery`
unconditionally wraps the user query in quotes and parses it even for a single
token.
This is pure wasted CPU on every single-term query that specifies `pf`, which
is the vast majority of search configurations. The fix is to add early returns
in both eDisMax (`addShingledPhraseQueries`) and DisMax (`getPhraseQuery`) to
bail out before any parsing work, when the resolved phrase would contain fewer
than 2 terms.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]