|
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; |
@@ -179,6 +182,19 @@ public void testPreProcess() throws Exception { |
179 | 182 | ParsedQuery parsedQuery = ParsedQuery.parsedMatchAllQuery(); |
180 | 183 | context3.sliceBuilder(null).parsedQuery(parsedQuery).preProcess(false); |
181 | 184 | assertEquals(context3.query(), context3.buildFilteredQuery(parsedQuery.query())); |
| 185 | + |
| 186 | + when(queryShardContext.getIndexSettings()).thenReturn(indexSettings); |
| 187 | + when(queryShardContext.fieldMapper(anyString())).thenReturn(mock(MappedFieldType.class)); |
| 188 | + when(shardSearchRequest.indexRoutings()).thenReturn(new String[0]); |
| 189 | + |
| 190 | + DefaultSearchContext context4 = new DefaultSearchContext(4L, shardSearchRequest, target, searcher, null, |
| 191 | + indexService, indexShard, bigArrays, null, timeout, null, Version.CURRENT); |
| 192 | + context4.sliceBuilder(new SliceBuilder(1,2)).parsedQuery(parsedQuery).preProcess(false); |
| 193 | + Query query1 = context4.query(); |
| 194 | + context4.sliceBuilder(new SliceBuilder(0,2)).parsedQuery(parsedQuery).preProcess(false); |
| 195 | + Query query2 = context4.query(); |
| 196 | + assertTrue(query1 instanceof MatchNoDocsQuery || query2 instanceof MatchNoDocsQuery); |
| 197 | + |
182 | 198 | } |
183 | 199 | } |
184 | 200 | } |
0 commit comments