Repository navigation
Throw TooManyClauses on intervals over-expansion - #16899
Open
mayya-sharipova wants to merge 1 commit into
Open
mayya-sharipova wants to merge 1 commit into
mayya-sharipova wants to merge 1 commit into
Conversation
Multi-term intervals sources (prefix, wildcard, regexp, fuzzy, range and multiterm) threw IllegalStateException when they expanded to more than maxExpansions terms. Lucene's exception types are: - IllegalArgumentException: invalid arguments at query build time - IllegalStateException: invalid internal state - TooManyClauses: a query that expands to too many terms Exceeding maxExpansions is not an invalid internal state. The query matched more terms than its limit allows, which is the caller's error. Throwing TooManyClauses lets applications built on Lucene recognise this user error by type and report it as such, rather than matching on the message of a generic IllegalStateException. maxExpansions is already capped at IndexSearcher#getMaxClauseCount. The matches() path now reports the pattern instead of the last matched term, so both paths produce the same message.
uchiha-asha
added a commit
to uchiha-asha/elasticsearch
that referenced
this pull request
Oct 23, 2026
Name the field and suggest a more selective pattern in the 400 message, add a TODO pointing to apache/lucene#16899, and lower the max clause count in IntervalQueriesIT so the test indexes only a few terms and asserts the exact limit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Throw TooManyClauses on intervals over-expansion
Multi-term intervals sources (prefix, wildcard, regexp, fuzzy, range
and multiterm) threw IllegalStateException when they expanded to more
than maxExpansions terms. Lucene's exception types are:
Exceeding maxExpansions is not an invalid internal state. The query
matched more terms than its limit allows, which is the caller's error.
Throwing TooManyClauses lets applications built on Lucene recognise this
user error by type and report it as such, rather than matching on the
message of a generic IllegalStateException. maxExpansions is already
capped at IndexSearcher#getMaxClauseCount.
The matches() path now reports the pattern instead of the last matched
term, so both paths produce the same message.