-
Notifications
You must be signed in to change notification settings - Fork 25k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NPE using bool filter with span_multi fuzzy query #52894
Comments
Pinging @elastic/es-search (:Search/Search) |
@cbuescher could you take a look at this one ? |
I took a look at the examples in #53118 and this and can reproduce the NPE on 6.8.7 locally with an index that contains at least one document containing the field that is queried by the fuzzy query, e.g:
This fails with the following stacktrace on 6.8.7, which is almost identical except for a missing
The outer boolean query surrounding the span query seems to be relevant, removing it doesn't seem to trigger the same rewrite path and the NPE. However, the same example works on 7.0.0, returning one document as expected, so I believe the reported problem is restricted to 6.8 (and possibly earlier). I haven't been able to check for any differences in the code on the call path yet, but here is the code that triggers the NPE on 6.8.7: The "atts" AttributeSource argument here seems to be null: Which gets passed down as a "null" value from I'm not sure yet why this isn't triggered e.g. when not the span in e.g. a "must" clause in the outer boolean query, nor why this is not a problem in 7.x any more, since the code in SpanBooleanQueryRewriteWithMaxClause hasn't changed, but I guess the rewriting taking place is different in that version. |
On 7.0 the recursive rewrite in the IndexSearcher doesn't seem to use |
This is the call stack on 7.0, the Attribute source that's |
I think I know why this fails in 6.8 inside a boolean filter now. The FuzzyQueryBuilder used to set the rewrite method in filter mode to "constant_score", which was later removed in 7.0 (https://github.com/elastic/elasticsearch/pull/35354/files#diff-82ebdac5b91f2d2f368f55eb1e738a39L329). The surrounding SpanMultiTermQueryBuilder#doToQuery then sees that in https://github.com/elastic/elasticsearch/blob/v6.8.7/server/src/main/java/org/elasticsearch/index/query/SpanMultiTermQueryBuilder.java#L169 and then uses SpanBooleanQueryRewriteWithMaxClause in the wrapper. I was able to reproduce the same NPE on 7.x and master by forcing the fuzzy query rewrite method to "constant_score" like this:
|
Under certain circumstances SpanMultiTermQueryWrapper uses SpanBooleanQueryRewriteWithMaxClause as its rewrite method, which in turn tries to get a TermsEnum from the wrapped MultiTermQuery currently using a `null` AttributeSource. While queries TermsQuery or subclasses of AutomatonQuery ignore this argument, FuzzyQuery uses it to create a FuzzyTermsEnum which triggers an NPE when the AttributeSource is not provided. This PR fixes this by supplying an empty AttributeSource instead of a `null` value. Closes elastic#52894
Under certain circumstances SpanMultiTermQueryWrapper uses SpanBooleanQueryRewriteWithMaxClause as its rewrite method, which in turn tries to get a TermsEnum from the wrapped MultiTermQuery currently using a `null` AttributeSource. While queries TermsQuery or subclasses of AutomatonQuery ignore this argument, FuzzyQuery uses it to create a FuzzyTermsEnum which triggers an NPE when the AttributeSource is not provided. This PR fixes this by supplying an empty AttributeSource instead of a `null` value. Closes #52894
Under certain circumstances SpanMultiTermQueryWrapper uses SpanBooleanQueryRewriteWithMaxClause as its rewrite method, which in turn tries to get a TermsEnum from the wrapped MultiTermQuery currently using a `null` AttributeSource. While queries TermsQuery or subclasses of AutomatonQuery ignore this argument, FuzzyQuery uses it to create a FuzzyTermsEnum which triggers an NPE when the AttributeSource is not provided. This PR fixes this by supplying an empty AttributeSource instead of a `null` value. Closes #52894
Under certain circumstances SpanMultiTermQueryWrapper uses SpanBooleanQueryRewriteWithMaxClause as its rewrite method, which in turn tries to get a TermsEnum from the wrapped MultiTermQuery currently using a `null` AttributeSource. While queries TermsQuery or subclasses of AutomatonQuery ignore this argument, FuzzyQuery uses it to create a FuzzyTermsEnum which triggers an NPE when the AttributeSource is not provided. This PR fixes this by supplying an empty AttributeSource instead of a `null` value. Closes #52894
Under certain circumstances SpanMultiTermQueryWrapper uses SpanBooleanQueryRewriteWithMaxClause as its rewrite method, which in turn tries to get a TermsEnum from the wrapped MultiTermQuery currently using a `null` AttributeSource. While queries TermsQuery or subclasses of AutomatonQuery ignore this argument, FuzzyQuery uses it to create a FuzzyTermsEnum which triggers an NPE when the AttributeSource is not provided. This PR fixes this by supplying an empty AttributeSource instead of a `null` value. Closes #52894
Elasticsearch version (
bin/elasticsearch --version
): 6.8.5Plugins installed: []
JVM version (
java -version
): openjdk version "13.0.1" 2019-10-15OS version (
uname -a
if on a Unix-like system): Linux 1f006eaddcb8 4.15.0-88-generic #88-Ubuntu SMP Tue Feb 11 20:11:34 UTC 2020 x86_64 x86_64 x86_64 GNU/LinuIssue:
The following query gives me a null pointer exception :
When using
must
instead offilter
, no more exception.No exception either when using a wildcard or a prefix instead of the fuzzy query.
Logs:
The text was updated successfully, but these errors were encountered: