-
Notifications
You must be signed in to change notification settings - Fork 25.2k
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
import org.apache.lucene.search.BooleanQuery; | ||
import org.apache.lucene.search.Collector; | ||
import org.apache.lucene.search.FieldDoc; | ||
import org.apache.lucene.search.MatchNoDocsQuery; | ||
import org.apache.lucene.search.Query; | ||
import org.elasticsearch.action.search.SearchShardTask; | ||
import org.elasticsearch.action.search.SearchType; | ||
|
@@ -274,7 +275,12 @@ && new NestedHelper(mapperService()).mightMatchNestedDocs(query) | |
} | ||
|
||
if (sliceBuilder != null) { | ||
filters.add(sliceBuilder.toFilter(clusterService, request, queryShardContext)); | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. nit: space before |
||
filters.add(slicedQuery); | ||
} | ||
} | ||
|
||
if (filters.isEmpty()) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,8 @@ | |
import org.apache.lucene.index.IndexReader; | ||
import org.apache.lucene.index.RandomIndexWriter; | ||
import org.apache.lucene.search.IndexSearcher; | ||
import org.apache.lucene.search.MatchNoDocsQuery; | ||
import org.apache.lucene.search.Query; | ||
import org.apache.lucene.search.QueryCachingPolicy; | ||
import org.apache.lucene.search.Sort; | ||
import org.apache.lucene.store.Directory; | ||
|
@@ -39,6 +41,7 @@ | |
import org.elasticsearch.index.cache.IndexCache; | ||
import org.elasticsearch.index.cache.query.QueryCache; | ||
import org.elasticsearch.index.engine.Engine; | ||
import org.elasticsearch.index.mapper.MappedFieldType; | ||
import org.elasticsearch.index.mapper.MapperService; | ||
import org.elasticsearch.index.query.AbstractQueryBuilder; | ||
import org.elasticsearch.index.query.ParsedQuery; | ||
|
@@ -57,6 +60,7 @@ | |
import java.util.UUID; | ||
|
||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.mockito.Matchers.anyInt; | ||
import static org.mockito.Matchers.anyObject; | ||
import static org.mockito.Matchers.anyString; | ||
import static org.mockito.Matchers.eq; | ||
|
@@ -178,6 +182,20 @@ public void testPreProcess() throws Exception { | |
ParsedQuery parsedQuery = ParsedQuery.parsedMatchAllQuery(); | ||
context3.sliceBuilder(null).parsedQuery(parsedQuery).preProcess(false); | ||
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 commentThe 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 commentThe 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. |
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. nit: |
||
indexService, indexShard, bigArrays, null, timeout, null); | ||
context4.sliceBuilder(new SliceBuilder(1,2)).parsedQuery(parsedQuery).preProcess(false); | ||
Query query1 = context4.query(); | ||
context4.sliceBuilder(new SliceBuilder(0,2)).parsedQuery(parsedQuery).preProcess(false); | ||
Query query2 = context4.query(); | ||
assertTrue(query1 instanceof MatchNoDocsQuery || query2 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
(