@@ -125,6 +125,7 @@ public void testSimpleMoreLikeThis() throws Exception {
125
125
client ().index (indexRequest ("test" ).id ("2" ).source (jsonBuilder ().startObject ().field ("text" , "lucene release" ).endObject ()))
126
126
.actionGet ();
127
127
client ().admin ().indices ().refresh (refreshRequest ()).actionGet ();
128
+ indexRandomForConcurrentSearch ("test" );
128
129
129
130
logger .info ("Running moreLikeThis" );
130
131
SearchResponse response = client ().prepareSearch ()
@@ -155,6 +156,7 @@ public void testSimpleMoreLikeThisWithTypes() throws Exception {
155
156
client ().index (indexRequest ("test" ).id ("2" ).source (jsonBuilder ().startObject ().field ("text" , "lucene release" ).endObject ()))
156
157
.actionGet ();
157
158
client ().admin ().indices ().refresh (refreshRequest ()).actionGet ();
159
+ indexRandomForConcurrentSearch ("test" );
158
160
159
161
logger .info ("Running moreLikeThis" );
160
162
SearchResponse response = client ().prepareSearch ()
@@ -190,6 +192,7 @@ public void testMoreLikeThisForZeroTokensInOneOfTheAnalyzedFields() throws Excep
190
192
).actionGet ();
191
193
192
194
client ().admin ().indices ().refresh (refreshRequest ()).actionGet ();
195
+ indexRandomForConcurrentSearch ("test" );
193
196
194
197
SearchResponse searchResponse = client ().prepareSearch ()
195
198
.setQuery (
@@ -256,6 +259,7 @@ public void testMoreLikeThisWithAliases() throws Exception {
256
259
client ().index (indexRequest ("test" ).id ("4" ).source (jsonBuilder ().startObject ().field ("text" , "opensearch release" ).endObject ()))
257
260
.actionGet ();
258
261
client ().admin ().indices ().refresh (refreshRequest ()).actionGet ();
262
+ indexRandomForConcurrentSearch ("test" );
259
263
260
264
logger .info ("Running moreLikeThis on index" );
261
265
SearchResponse response = client ().prepareSearch ()
@@ -304,6 +308,7 @@ public void testMoreLikeThisWithAliasesInLikeDocuments() throws Exception {
304
308
client ().index (indexRequest (indexName ).id ("3" ).source (jsonBuilder ().startObject ().field ("text" , "opensearch index" ).endObject ()))
305
309
.actionGet ();
306
310
refresh (indexName );
311
+ indexRandomForConcurrentSearch (indexName );
307
312
308
313
SearchResponse response = client ().prepareSearch ()
309
314
.setQuery (new MoreLikeThisQueryBuilder (null , new Item [] { new Item (aliasName , "1" ) }).minTermFreq (1 ).minDocFreq (1 ))
@@ -321,6 +326,7 @@ public void testMoreLikeThisIssue2197() throws Exception {
321
326
.get ();
322
327
client ().admin ().indices ().prepareRefresh ("foo" ).get ();
323
328
assertThat (ensureGreen (), equalTo (ClusterHealthStatus .GREEN ));
329
+ indexRandomForConcurrentSearch ("foo" );
324
330
325
331
SearchResponse response = client ().prepareSearch ()
326
332
.setQuery (new MoreLikeThisQueryBuilder (null , new Item [] { new Item ("foo" , "1" ) }))
@@ -344,6 +350,7 @@ public void testMoreLikeWithCustomRouting() throws Exception {
344
350
.setRouting ("2" )
345
351
.get ();
346
352
client ().admin ().indices ().prepareRefresh ("foo" ).get ();
353
+ indexRandomForConcurrentSearch ("foo" );
347
354
348
355
SearchResponse response = client ().prepareSearch ()
349
356
.setQuery (new MoreLikeThisQueryBuilder (null , new Item [] { new Item ("foo" , "1" ).routing ("2" ) }))
@@ -368,6 +375,7 @@ public void testMoreLikeThisIssueRoutingNotSerialized() throws Exception {
368
375
.setRouting ("4000" )
369
376
.get ();
370
377
client ().admin ().indices ().prepareRefresh ("foo" ).get ();
378
+ indexRandomForConcurrentSearch ("foo" );
371
379
SearchResponse response = client ().prepareSearch ()
372
380
.setQuery (new MoreLikeThisQueryBuilder (null , new Item [] { new Item ("foo" , "1" ).routing ("4000" ) }))
373
381
.get ();
@@ -401,6 +409,7 @@ public void testNumericField() throws Exception {
401
409
.get ();
402
410
403
411
refresh ();
412
+ indexRandomForConcurrentSearch ("test" );
404
413
405
414
// Implicit list of fields -> ignore numeric fields
406
415
SearchResponse searchResponse = client ().prepareSearch ()
@@ -508,6 +517,7 @@ public void testMoreLikeThisWithFieldAlias() throws Exception {
508
517
index ("test" , "_doc" , "1" , "text" , "lucene" );
509
518
index ("test" , "_doc" , "2" , "text" , "lucene release" );
510
519
refresh ();
520
+ indexRandomForConcurrentSearch ("test" );
511
521
512
522
Item item = new Item ("test" , "1" );
513
523
QueryBuilder query = QueryBuilders .moreLikeThisQuery (new String [] { "alias" }, null , new Item [] { item })
@@ -548,6 +558,7 @@ public void testSimpleMoreLikeInclude() throws Exception {
548
558
.source (jsonBuilder ().startObject ().field ("text" , "Lucene has been ported to other programming languages" ).endObject ())
549
559
).actionGet ();
550
560
client ().admin ().indices ().refresh (refreshRequest ()).actionGet ();
561
+ indexRandomForConcurrentSearch ("test" );
551
562
552
563
logger .info ("Running More Like This with include true" );
553
564
SearchResponse response = client ().prepareSearch ()
@@ -832,11 +843,12 @@ public void testSelectFields() throws IOException, ExecutionException, Interrupt
832
843
assertHitCount (response , 1 );
833
844
}
834
845
835
- public void testWithRouting () throws IOException {
846
+ public void testWithRouting () throws IOException , InterruptedException {
836
847
client ().prepareIndex ("index" ).setId ("1" ).setRouting ("3" ).setSource ("text" , "this is a document" ).get ();
837
848
client ().prepareIndex ("index" ).setId ("2" ).setRouting ("1" ).setSource ("text" , "this is another document" ).get ();
838
849
client ().prepareIndex ("index" ).setId ("3" ).setRouting ("4" ).setSource ("text" , "this is yet another document" ).get ();
839
850
refresh ("index" );
851
+ indexRandomForConcurrentSearch ("index" );
840
852
841
853
Item item = new Item ("index" , "2" ).routing ("1" );
842
854
MoreLikeThisQueryBuilder moreLikeThisQueryBuilder = new MoreLikeThisQueryBuilder (
0 commit comments