Anshum Gupta created SOLR-18691:
-----------------------------------
Summary: Phrase queries on fields indexed without positions
return HTTP 500 instead of 400, and edismax pf/pf2/pf3 on such fields fail the
whole request
Key: SOLR-18691
URL: https://issues.apache.org/jira/browse/SOLR-18691
Project: Solr
Issue Type: Bug
Components: query parsers
Reporter: Anshum Gupta
Assignee: Anshum Gupta
If a field is indexed without position data ({{omitPositions="true"}} or
{{omitTermFreqAndPositions="true"}}), Lucene can't run a {{PhraseQuery}} or
{{MultiPhraseQuery}} on it. It throws an {{IllegalStateException}} when the
query is executed.
Lucene is expected to throw the exception as it fails fast.
The problem is what Solr does with it. The exception isn't a {{SolrException}},
so {{ResponseUtils.getErrorInfo}} turns it into an *HTTP 500* and logs it at
ERROR ({{"500 Exception"}}) with a full stack trace.
Two different situations end up in the same place:
# *Explicit phrase.* The user writes a quoted phrase on that field. The query
doesn't fit the schema, so it's a client error and should get a *400* with a
clear message, not a 500.
# *Implicit phrase boost (edismax pf/pf2/pf3).* The user never wrote a phrase.
Edismax builds phrase clauses from the query terms in
{{addShingledPhraseQueries}} and adds them as optional SHOULD boosts. If any
{{pf*}} field has no positions, *the whole request fails with a 500*, even
though the user's query is valid. This is the more serious case: a ranking
boost that is only meant to help should never fail a request.
The second case is easy to hit in production. Someone adds a field to a shared
{{pf2}} default in solrconfig.xml. Or someone switches a field type to
{{omitPositions}} to save index space without checking which request handlers
use it for phrase boosts. After that, every multi-term query that reaches the
handler fails.
h2. Impact:
* Valid end-user queries fail completely (case 2).
* Client errors are reported as server errors. That inflates 5xx rates and
alerting, and clients and load balancers that treat 5xx as retryable may retry
or fail over for no reason.
* ERROR-level stack traces appear in the logs for what is really a
configuration or query problem.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]