|
22 | 22 | import org.apache.lucene.index.IndexReader;
|
23 | 23 | import org.apache.lucene.index.RandomIndexWriter;
|
24 | 24 | import org.apache.lucene.search.IndexSearcher;
|
| 25 | +import org.apache.lucene.search.MatchNoDocsQuery; |
| 26 | +import org.apache.lucene.search.Query; |
25 | 27 | import org.apache.lucene.search.QueryCachingPolicy;
|
26 | 28 | import org.apache.lucene.search.Sort;
|
27 | 29 | import org.apache.lucene.store.Directory;
|
|
39 | 41 | import org.elasticsearch.index.cache.IndexCache;
|
40 | 42 | import org.elasticsearch.index.cache.query.QueryCache;
|
41 | 43 | import org.elasticsearch.index.engine.Engine;
|
| 44 | +import org.elasticsearch.index.mapper.MappedFieldType; |
42 | 45 | import org.elasticsearch.index.mapper.MapperService;
|
43 | 46 | import org.elasticsearch.index.query.AbstractQueryBuilder;
|
44 | 47 | import org.elasticsearch.index.query.ParsedQuery;
|
@@ -178,6 +181,19 @@ public void testPreProcess() throws Exception {
|
178 | 181 | ParsedQuery parsedQuery = ParsedQuery.parsedMatchAllQuery();
|
179 | 182 | context3.sliceBuilder(null).parsedQuery(parsedQuery).preProcess(false);
|
180 | 183 | assertEquals(context3.query(), context3.buildFilteredQuery(parsedQuery.query()));
|
| 184 | + |
| 185 | + when(queryShardContext.getIndexSettings()).thenReturn(indexSettings); |
| 186 | + when(queryShardContext.fieldMapper(anyString())).thenReturn(mock(MappedFieldType.class)); |
| 187 | + when(shardSearchRequest.indexRoutings()).thenReturn(new String[0]); |
| 188 | + |
| 189 | + DefaultSearchContext context4 = new DefaultSearchContext(4L, shardSearchRequest, target, searcher, null, |
| 190 | + indexService, indexShard, bigArrays, null, timeout, null); |
| 191 | + context4.sliceBuilder(new SliceBuilder(1,2)).parsedQuery(parsedQuery).preProcess(false); |
| 192 | + Query query1 = context4.query(); |
| 193 | + context4.sliceBuilder(new SliceBuilder(0,2)).parsedQuery(parsedQuery).preProcess(false); |
| 194 | + Query query2 = context4.query(); |
| 195 | + assertTrue(query1 instanceof MatchNoDocsQuery || query2 instanceof MatchNoDocsQuery); |
| 196 | + |
181 | 197 | }
|
182 | 198 | }
|
183 | 199 | }
|
0 commit comments