From 01bbdcee5faa45f37d26c9a0bf68c09ac9f58e44 Mon Sep 17 00:00:00 2001 From: zhouhui Date: Thu, 14 Nov 2024 10:43:53 +0800 Subject: [PATCH] Update test cases. --- .../org/apache/lucene/index/TestIndexWriter.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java index ad26e7234c7..c0def43259c 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java @@ -232,8 +232,10 @@ public class TestIndexWriter extends LuceneTestCase { writer.addDocument(doc); } writer.flush(); - writer.deleteDocuments( - LongPoint.newRangeQuery("content", 10, 19), LongPoint.newRangeQuery("content", 12, 15)); + // Match all docs in 2nd segment. + writer.deleteDocuments(LongPoint.newRangeQuery("content", 10, 19)); + // This query can not be applied on 2nd segment, since it is fully deleted by prior query. + writer.deleteDocuments(LongPoint.newRangeQuery("content", 12, 15)); DirectoryReader reader = DirectoryReader.open(writer); IndexSearcher searcher = newSearcher(reader); @@ -259,20 +261,25 @@ public class TestIndexWriter extends LuceneTestCase { doc = new Document(); doc.add(new TextField("f", "foo bar tea", Field.Store.NO)); writer.addDocument(doc); + writer.flush(); doc = new Document(); doc.add(new TextField("f", "foo bar", Field.Store.NO)); writer.addDocument(doc); + writer.flush(); doc = new Document(); doc.add(new TextField("f", "foo tea", Field.Store.NO)); writer.addDocument(doc); - writer.flush(); Term[] delTerms = new Term[3]; + // This query only can be applied on 3rd segment, since segment 1, 2 are fully deleted by prior + // query. delTerms[0] = new Term("f", "foo"); + // This query can be applied on every segment, since it is executed firstly. delTerms[1] = new Term("f", "bar"); + // This query can not be applied, since all segments are fully deleted by prior query. delTerms[2] = new Term("f", "tea"); writer.deleteDocuments(delTerms);