-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Short circuited to MatchNone for non-participating slice #51207
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
Conversation
In case of numSlices = numShards , use a MatchNone query instead of boolean with a MatchNone - MUST clause
|
Pinging @elastic/es-search (:Search/Search) |
|
@elasticmachine test this please |
mayya-sharipova
left a comment
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 @nirmalc, nice enhancement!
I left small comments to be addressed
| Query slicedQuery = sliceBuilder.toFilter(clusterService, request, queryShardContext); | ||
| if ( slicedQuery instanceof MatchNoDocsQuery){ | ||
| return slicedQuery; | ||
| }else { |
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.
nit: space before else
| if (sliceBuilder != null) { | ||
| filters.add(sliceBuilder.toFilter(clusterService, request, queryShardContext)); | ||
| Query slicedQuery = sliceBuilder.toFilter(clusterService, request, queryShardContext); | ||
| if ( slicedQuery instanceof MatchNoDocsQuery){ |
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.
extra space after (
| when(queryShardContext.fieldMapper(anyString())).thenReturn(mock(MappedFieldType.class)); | ||
| when(shardSearchRequest.indexRoutings()).thenReturn(new String[0]); | ||
|
|
||
| DefaultSearchContext context4 = new DefaultSearchContext(3L, shardSearchRequest, target, searcher, null, |
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.
nit: new DefaultSearchContext(3L, => new DefaultSearchContext(4L,
| assertEquals(context3.query(), context3.buildFilteredQuery(parsedQuery.query())); | ||
|
|
||
| when(queryShardContext.getIndexSettings()).thenReturn(indexSettings); | ||
| when(indexService.newQueryShardContext(anyInt(),anyObject(),anyObject(),anyString())).thenReturn(queryShardContext); |
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.
Looks like, line 187 in not necessary
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 for review , it is not necessary. I think i added in my first attempt to include use-case with routings in test. I've reformatted code with intelliJ - sorry for formatting issues.
|
@elasticmachine test this please |
|
@elasticmachine run elasticsearch-ci/default-distro |
|
@elasticmachine run elasticsearch-ci/bwc |
|
@elasticmachine update branch |
|
@elasticmachine test this please |
In case of numSlices = numShards, use a MatchNone query instead of boolean with a MatchNone - MUST clause Backport for #51207
|
@nirmalc Thank you for the PR, your change has ben merged, and will be available from 7.7 |
When the query is expensive parallel usage of scroll/slice API overloads cluster, ( In my case a
span_multiquery causes heap / gc issues )Looks like its because same query is processed against all non-matching shards with a
MatchNoDocsand matching-shards withMatchAllDocsfilter. In case of number of shards =< number of slices, returning aMatchNoDocsquery instead of filter seems to avoid that problem.