test: ensure we endup with a single segment

Closes #28127
This commit is contained in:
Martijn van Groningen 2018-01-10 15:14:13 +01:00
parent fcf4114adc
commit 73f6857dff
No known key found for this signature in database
GPG Key ID: AB236F4FCF2AF12A
1 changed files with 5 additions and 3 deletions

View File

@ -555,18 +555,20 @@ public class CandidateQueryTests extends ESSingleNodeTestCase {
try (RAMDirectory directory = new RAMDirectory()) {
try (IndexWriter iw = new IndexWriter(directory, newIndexWriterConfig())) {
List<Document> documents = new ArrayList<>();
Document document = new Document();
document.add(new StringField("field", "value1", Field.Store.NO));
document.add(new StringField("field", "value2", Field.Store.NO));
iw.addDocument(document);
documents.add(document);
document = new Document();
document.add(new StringField("field", "value5", Field.Store.NO));
document.add(new StringField("field", "value6", Field.Store.NO));
iw.addDocument(document);
documents.add(document);
document = new Document();
document.add(new StringField("field", "value3", Field.Store.NO));
document.add(new StringField("field", "value4", Field.Store.NO));
iw.addDocument(document);
documents.add(document);
iw.addDocuments(documents); // IW#addDocuments(...) ensures we end up with a single segment
}
try (IndexReader ir = DirectoryReader.open(directory)){
IndexSearcher percolateSearcher = new IndexSearcher(ir);