Skip to content

Commit

Permalink
TermsAggregatorTests flaky test fix (#13567) (#13738)
Browse files Browse the repository at this point in the history
(cherry picked from commit d26cd46)

Signed-off-by: Sandesh Kumar <sandeshkr419@gmail.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent e018125 commit 215ffc8
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -353,33 +353,40 @@ private void testSimple(
newIndexWriterConfig().setMergePolicy(NoMergePolicy.INSTANCE)
)
) {
List<Document> documents = new ArrayList<>();
Document document = new Document();
addFieldConsumer.apply(document, "string", "a");
addFieldConsumer.apply(document, "string", "b");
indexWriter.addDocument(document);
documents.add(document);

document = new Document();
addFieldConsumer.apply(document, "string", "");
addFieldConsumer.apply(document, "string", "c");
addFieldConsumer.apply(document, "string", "a");
indexWriter.addDocument(document);
documents.add(document);

document = new Document();
addFieldConsumer.apply(document, "string", "b");
addFieldConsumer.apply(document, "string", "d");
indexWriter.addDocument(document);
documents.add(document);

document = new Document();
addFieldConsumer.apply(document, "string", "");
if (includeDocCountField) {
// Adding _doc_count to one document
document.add(new NumericDocValuesField("_doc_count", 10));
}
indexWriter.addDocument(document);
documents.add(document);

if (includeDeletedDocumentsInSegment) {
document = new Document();
ADD_SORTED_SET_FIELD_INDEXED.apply(document, "string", "e");
indexWriter.addDocument(document);
documents.add(document);
indexWriter.addDocuments(documents);
indexWriter.deleteDocuments(new Term("string", "e"));
assertEquals(5, indexWriter.getDocStats().maxDoc); // deleted document still in segment
} else {
indexWriter.addDocuments(documents);
}

try (IndexReader indexReader = maybeWrapReaderEs(indexWriter.getReader())) {
Expand Down

0 comments on commit 215ffc8

Please sign in to comment.