95
95
import org .elasticsearch .index .mapper .MapperService ;
96
96
import org .elasticsearch .index .mapper .NumberFieldMapper ;
97
97
import org .elasticsearch .index .mapper .ParseContext ;
98
- import org .elasticsearch .index .query .QueryShardContext ;
99
98
import org .elasticsearch .plugins .Plugin ;
100
99
import org .elasticsearch .test .ESSingleNodeTestCase ;
101
100
import org .junit .After ;
@@ -124,7 +123,6 @@ public class CandidateQueryTests extends ESSingleNodeTestCase {
124
123
private IndexWriter indexWriter ;
125
124
private DocumentMapper documentMapper ;
126
125
private DirectoryReader directoryReader ;
127
- private IndexService indexService ;
128
126
private MapperService mapperService ;
129
127
130
128
private PercolatorFieldMapper fieldMapper ;
@@ -146,7 +144,7 @@ public void init() throws Exception {
146
144
indexWriter = new IndexWriter (directory , config );
147
145
148
146
String indexName = "test" ;
149
- indexService = createIndex (indexName , Settings .EMPTY );
147
+ IndexService indexService = createIndex (indexName , Settings .EMPTY );
150
148
mapperService = indexService .mapperService ();
151
149
152
150
String mapper = Strings .toString (XContentFactory .jsonBuilder ().startObject ().startObject ("type" )
@@ -199,7 +197,6 @@ public void testDuel() throws Exception {
199
197
}
200
198
Collections .sort (intValues );
201
199
202
- QueryShardContext context = createSearchContext (indexService ).getQueryShardContext ();
203
200
MappedFieldType intFieldType = mapperService .fieldType ("int_field" );
204
201
205
202
List <Supplier <Query >> queryFunctions = new ArrayList <>();
@@ -210,10 +207,10 @@ public void testDuel() throws Exception {
210
207
queryFunctions .add (() -> new TermQuery (new Term (field1 , randomFrom (stringContent .get (field1 )))));
211
208
String field2 = randomFrom (stringFields );
212
209
queryFunctions .add (() -> new TermQuery (new Term (field2 , randomFrom (stringContent .get (field2 )))));
213
- queryFunctions .add (() -> intFieldType .termQuery (randomFrom (intValues ), context ));
214
- queryFunctions .add (() -> intFieldType .termsQuery (Arrays .asList (randomFrom (intValues ), randomFrom (intValues )), context ));
210
+ queryFunctions .add (() -> intFieldType .termQuery (randomFrom (intValues ), null ));
211
+ queryFunctions .add (() -> intFieldType .termsQuery (Arrays .asList (randomFrom (intValues ), randomFrom (intValues )), null ));
215
212
queryFunctions .add (() -> intFieldType .rangeQuery (intValues .get (4 ), intValues .get (intValues .size () - 4 ), true ,
216
- true , ShapeRelation .WITHIN , null , null , context ));
213
+ true , ShapeRelation .WITHIN , null , null , null ));
217
214
queryFunctions .add (() -> new TermInSetQuery (field1 , new BytesRef (randomFrom (stringContent .get (field1 ))),
218
215
new BytesRef (randomFrom (stringContent .get (field1 )))));
219
216
queryFunctions .add (() -> new TermInSetQuery (field2 , new BytesRef (randomFrom (stringContent .get (field1 ))),
@@ -338,7 +335,6 @@ public void testDuel2() throws Exception {
338
335
ranges .add (new int []{0 , 10 });
339
336
ranges .add (new int []{15 , 50 });
340
337
341
- QueryShardContext context = createSearchContext (indexService ).getQueryShardContext ();
342
338
List <ParseContext .Document > documents = new ArrayList <>();
343
339
{
344
340
addQuery (new TermQuery (new Term ("string_field" , randomFrom (stringValues ))), documents );
@@ -348,13 +344,13 @@ public void testDuel2() throws Exception {
348
344
}
349
345
{
350
346
int [] range = randomFrom (ranges );
351
- Query rangeQuery = intFieldType .rangeQuery (range [0 ], range [1 ], true , true , null , null , null , context );
347
+ Query rangeQuery = intFieldType .rangeQuery (range [0 ], range [1 ], true , true , null , null , null , null );
352
348
addQuery (rangeQuery , documents );
353
349
}
354
350
{
355
351
int numBooleanQueries = randomIntBetween (1 , 5 );
356
352
for (int i = 0 ; i < numBooleanQueries ; i ++) {
357
- Query randomBQ = randomBQ (1 , stringValues , ranges , intFieldType , context );
353
+ Query randomBQ = randomBQ (1 , stringValues , ranges , intFieldType );
358
354
addQuery (randomBQ , documents );
359
355
}
360
356
}
@@ -379,7 +375,6 @@ public void testDuel2() throws Exception {
379
375
MemoryIndex memoryIndex = MemoryIndex .fromDocument (document , new WhitespaceAnalyzer ());
380
376
duelRun (queryStore , memoryIndex , shardSearcher );
381
377
}
382
-
383
378
for (int [] range : ranges ) {
384
379
List <Field > numberFields =
385
380
NumberFieldMapper .NumberType .INTEGER .createFields ("int_field" , between (range [0 ], range [1 ]), true , true , false );
@@ -392,8 +387,7 @@ public void testDuel2() throws Exception {
392
387
}
393
388
}
394
389
395
- private BooleanQuery randomBQ (int depth , List <String > stringValues , List <int []> ranges ,
396
- MappedFieldType intFieldType , QueryShardContext context ) {
390
+ private BooleanQuery randomBQ (int depth , List <String > stringValues , List <int []> ranges , MappedFieldType intFieldType ) {
397
391
final int numClauses = randomIntBetween (1 , 4 );
398
392
final boolean onlyShouldClauses = randomBoolean ();
399
393
final BooleanQuery .Builder builder = new BooleanQuery .Builder ();
@@ -402,10 +396,10 @@ private BooleanQuery randomBQ(int depth, List<String> stringValues, List<int[]>
402
396
for (int i = 0 ; i < numClauses ; i ++) {
403
397
Query subQuery ;
404
398
if (randomBoolean () && depth <= 3 ) {
405
- subQuery = randomBQ (depth + 1 , stringValues , ranges , intFieldType , context );
399
+ subQuery = randomBQ (depth + 1 , stringValues , ranges , intFieldType );
406
400
} else if (randomBoolean ()) {
407
401
int [] range = randomFrom (ranges );
408
- subQuery = intFieldType .rangeQuery (range [0 ], range [1 ], true , true , null , null , null , context );
402
+ subQuery = intFieldType .rangeQuery (range [0 ], range [1 ], true , true , null , null , null , null );
409
403
} else {
410
404
subQuery = new TermQuery (new Term ("string_field" , randomFrom (stringValues )));
411
405
}
0 commit comments