Update test cases.

This commit is contained in:
zhouhui 2024-11-14 10:43:53 +08:00
parent 7cab16f72d
commit 01bbdcee5f
1 changed files with 10 additions and 3 deletions

View File

@ -232,8 +232,10 @@ public class TestIndexWriter extends LuceneTestCase {
writer.addDocument(doc); writer.addDocument(doc);
} }
writer.flush(); writer.flush();
writer.deleteDocuments( // Match all docs in 2nd segment.
LongPoint.newRangeQuery("content", 10, 19), LongPoint.newRangeQuery("content", 12, 15)); 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); DirectoryReader reader = DirectoryReader.open(writer);
IndexSearcher searcher = newSearcher(reader); IndexSearcher searcher = newSearcher(reader);
@ -259,20 +261,25 @@ public class TestIndexWriter extends LuceneTestCase {
doc = new Document(); doc = new Document();
doc.add(new TextField("f", "foo bar tea", Field.Store.NO)); doc.add(new TextField("f", "foo bar tea", Field.Store.NO));
writer.addDocument(doc); writer.addDocument(doc);
writer.flush();
doc = new Document(); doc = new Document();
doc.add(new TextField("f", "foo bar", Field.Store.NO)); doc.add(new TextField("f", "foo bar", Field.Store.NO));
writer.addDocument(doc); writer.addDocument(doc);
writer.flush();
doc = new Document(); doc = new Document();
doc.add(new TextField("f", "foo tea", Field.Store.NO)); doc.add(new TextField("f", "foo tea", Field.Store.NO));
writer.addDocument(doc); writer.addDocument(doc);
writer.flush(); writer.flush();
Term[] delTerms = new Term[3]; 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"); 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"); 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"); delTerms[2] = new Term("f", "tea");
writer.deleteDocuments(delTerms); writer.deleteDocuments(delTerms);