@@ -353,33 +353,40 @@ private void testSimple(
353
353
newIndexWriterConfig ().setMergePolicy (NoMergePolicy .INSTANCE )
354
354
)
355
355
) {
356
+ List <Document > documents = new ArrayList <>();
356
357
Document document = new Document ();
357
358
addFieldConsumer .apply (document , "string" , "a" );
358
359
addFieldConsumer .apply (document , "string" , "b" );
359
- indexWriter .addDocument (document );
360
+ documents .add (document );
361
+
360
362
document = new Document ();
361
363
addFieldConsumer .apply (document , "string" , "" );
362
364
addFieldConsumer .apply (document , "string" , "c" );
363
365
addFieldConsumer .apply (document , "string" , "a" );
364
- indexWriter .addDocument (document );
366
+ documents .add (document );
367
+
365
368
document = new Document ();
366
369
addFieldConsumer .apply (document , "string" , "b" );
367
370
addFieldConsumer .apply (document , "string" , "d" );
368
- indexWriter .addDocument (document );
371
+ documents .add (document );
372
+
369
373
document = new Document ();
370
374
addFieldConsumer .apply (document , "string" , "" );
371
375
if (includeDocCountField ) {
372
376
// Adding _doc_count to one document
373
377
document .add (new NumericDocValuesField ("_doc_count" , 10 ));
374
378
}
375
- indexWriter . addDocument (document );
379
+ documents . add (document );
376
380
377
381
if (includeDeletedDocumentsInSegment ) {
378
382
document = new Document ();
379
383
ADD_SORTED_SET_FIELD_INDEXED .apply (document , "string" , "e" );
380
- indexWriter .addDocument (document );
384
+ documents .add (document );
385
+ indexWriter .addDocuments (documents );
381
386
indexWriter .deleteDocuments (new Term ("string" , "e" ));
382
387
assertEquals (5 , indexWriter .getDocStats ().maxDoc ); // deleted document still in segment
388
+ } else {
389
+ indexWriter .addDocuments (documents );
383
390
}
384
391
385
392
try (IndexReader indexReader = maybeWrapReaderEs (indexWriter .getReader ())) {
0 commit comments