romseygeek commented on code in PR #16061:
URL: https://github.com/apache/lucene/pull/16061#discussion_r3240966220
##########
lucene/core/src/test/org/apache/lucene/search/TestDocValuesQueries.java:
##########
@@ -750,4 +751,41 @@ public void testRewriteWorksWithPointsButNoSkipIndex()
throws IOException {
}
}
}
+
+ public void testPrimarySortDenseSortedDocValuesExactMatch() throws
IOException {
+ Directory dir = newDirectory();
+ IndexWriterConfig config = new IndexWriterConfig().setCodec(getCodec());
+ config.setIndexSort(
+ new Sort(new SortField("dv", SortField.Type.STRING,
random().nextBoolean())));
+ int numBlocks = random().nextInt(4, 16);
+ int[] sizes = new int[numBlocks];
+ for (int i = 0; i < numBlocks; i++) {
+ sizes[i] = random().nextInt(1, 250);
+ }
+ RandomIndexWriter iw = new RandomIndexWriter(random(), dir, config);
+ for (int i = 0; i < numBlocks; i++) {
+ BytesRef bytesRef = new BytesRef("" + i);
+ for (int j = 0; j < sizes[i]; j++) {
+ Document doc = new Document();
+ doc.add(SortedDocValuesField.indexedField("dv", bytesRef));
+ iw.addDocument(doc);
+ }
+ }
+ iw.commit();
+ iw.forceMerge(1);
+
+ final IndexReader reader = iw.getReader();
+ final IndexSearcher searcher = newSearcher(reader, false);
+ iw.close();
+
+ for (int i = 0; i < numBlocks; i++) {
+ final Query q1 =
+ SortedDocValuesField.newSlowRangeQuery(
+ "dv", new BytesRef("" + i), new BytesRef("" + i), true, true);
+ assertEquals(sizes[i], searcher.count(q1));
+ assertEquals(sizes[i], searcher.search(q1, 1000).totalHits.value());
+ }
+ reader.close();
+ dir.close();
+ }
Review Comment:
Can we add a test that explicitly checks the cost calculations?
--
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]