-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Fixes a bug in interval filter serialization #49793
Conversation
Pinging @elastic/es-search (:Search/Search) |
@romseygeek you will also want to fix |
Good catch, thanks @mattweber ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@romseygeek the fix LGTM, but we have a bit of a hole in our testing here that I pointed out in a comment. Would you mind opening a follow up issue that we need to maybe need some unit test for the various IntervalsSourceProviders directly?
return new IntervalsSourceProvider.IntervalFilter(createRandomSource(depth + 1), randomFrom(filters)); | ||
} | ||
return new IntervalsSourceProvider.IntervalFilter( | ||
new Script(ScriptType.INLINE, "mockscript", "1", Collections.emptyMap())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding these two variations is great to catch the xContent NPE but unfortunately doesn't directly trigger the Equals/Hashcode tests for the query builder due to a lack of coverage we have here (see https://github.com/elastic/elasticsearch/blob/master/test/framework/src/main/java/org/elasticsearch/test/AbstractQueryTestCase.java#L578). Without the equals/hashCode fixes this will trigger some of the "cachability" tests in this class, but very rarely.
I think adding these tests is out of scope for this PR but we should open an issue to maybe test wire- and xContent serialization of all the IntervalsSourceProvider implementations directly in unit tests. There seem to be none at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @cbuescher , I opened #49820 as a followup
There is a possible NPE in IntervalFilter xcontent serialization when scripts are used, and `equals` and `hashCode` are also incorrectly implemented for script filters. This commit fixes both.
#49793 added test coverage for interval queries that contain script filters, but did not adjust testCacheability(), which how fails occasionally when given a random interval source containing a script. This commit overrides testCacheability() to explicitly sources with and without script filters. Fixes #49821
@mattweber @romseygeek, thanks for reporting and fixing this. I too was struggling with this problem for a week and trying to search the documentation/source code if I'm making any mistake. Finally, I've reported this yesterday found myself convinced that it is an issue in the elastic code.: #50036 Just a quick question. Is it possible to backport this to 7.3.x branch? |
@romseygeek @cbuescher Any ideas if this can be backported to 7.3.x fix branch? |
@gpcmol we don't do patch releases on older minor versions, and since 7.5.1 is already out, thats the version we are currently releasing patches for. |
There is a possible NPE in IntervalFilter xcontent serialization when scripts are used, and `equals` and `hashCode` are also incorrectly implemented for script filters. This commit fixes both.
…9824) elastic#49793 added test coverage for interval queries that contain script filters, but did not adjust testCacheability(), which how fails occasionally when given a random interval source containing a script. This commit overrides testCacheability() to explicitly sources with and without script filters. Fixes elastic#49821
Hi @romseygeek, thanks for fixing this bug. Just a question, how do I use this filter if I have to query for Something like: |
Hi @prasad2kin, you should be able to use something like:
|
Thanks for this Alan ( @romseygeek ). I'll try it. The above was a simple example, but I've use cases where I have a mix of wildcards + terms or fuzzy snippets. Essentially, I was after getting an equivalent of |
@mattweber found an error in interval script filter serialization as part of #49519,
which I'm pulling out and fixing separately here.