gaobinlong commented on code in PR #15653:
URL: https://github.com/apache/lucene/pull/15653#discussion_r3218029365
##########
lucene/misc/src/test/org/apache/lucene/misc/search/TestDocValuesStatsCollector.java:
##########
@@ -99,226 +104,243 @@ public void testOneDoc() throws IOException {
}
public void testDocsWithLongValues() throws IOException {
- try (Directory dir = newDirectory();
- IndexWriter indexWriter = new IndexWriter(dir,
newIndexWriterConfig())) {
- String field = "numeric";
- int numDocs = TestUtil.nextInt(random(), 1, 100);
- long[] docValues = new long[numDocs];
- int nextVal = 1;
- for (int i = 0; i < numDocs; i++) {
- Document doc = new Document();
- if (random().nextBoolean()) { // not all documents have a value
- doc.add(new NumericDocValuesField(field, nextVal));
- doc.add(new StringField("id", "doc" + i, Store.NO));
- docValues[i] = nextVal;
- ++nextVal;
- }
- indexWriter.addDocument(doc);
- }
-
- // 20% of cases delete some docs
- if (random().nextDouble() < 0.2) {
+ try (Directory dir = newDirectory()) {
+ IndexWriterConfig config = newIndexWriterConfig();
+ try (RandomIndexWriter indexWriter = new RandomIndexWriter(random(),
dir, config)) {
+ String field = "numeric";
+ int numDocs = TestUtil.nextInt(random(), 1, 100);
+ long[] docValues = new long[numDocs];
+ int nextVal = 1;
for (int i = 0; i < numDocs; i++) {
+ Document doc = new Document();
if (random().nextBoolean()) {
- indexWriter.deleteDocuments(new Term("id", "doc" + i));
- docValues[i] = 0;
+ doc.add(new NumericDocValuesField(field, nextVal));
+ doc.add(new StringField("id", "doc" + i, Store.NO));
+ docValues[i] = nextVal;
+ ++nextVal;
}
+ indexWriter.addDocument(doc);
}
- }
- try (DirectoryReader reader = DirectoryReader.open(indexWriter)) {
- IndexSearcher searcher = new IndexSearcher(reader);
Review Comment:
I think no, we also need RandomIndexWriter to generate more segments.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]