LuXugang commented on PR #12405:
URL: https://github.com/apache/lucene/pull/12405#issuecomment-1613330925

   ```java
     public void test() throws IOException {
       final Directory dir = newDirectory();
       IndexWriterConfig config =
               new IndexWriterConfig()
                       // Make sure to use the default codec, otherwise some 
random points formats that have
                       // large values for maxPointsPerLeaf might not enable 
skipping with only 10k docs
                       .setCodec(TestUtil.getDefaultCodec());
       final IndexWriter writer = new IndexWriter(dir, config);
       final int numDocs = atLeast(10000);
       final int missValuesNumDocs = numDocs / 2;
       for (int i = 0; i < numDocs; ++i) {
         final Document doc = new Document();
         if (i <= missValuesNumDocs) { // missing value document
         } else {
           doc.add(new NumericDocValuesField("my_field", i));
           doc.add(new LongPoint("my_field", i));
         }
         writer.addDocument(doc);
       }
       final IndexReader reader = DirectoryReader.open(writer);
       writer.close();
       // single threaded so totalHits is deterministic
       IndexSearcher searcher =
               newSearcher(reader, random().nextBoolean(), 
random().nextBoolean(), false);
       final int numHits = 3;
       final int totalHitsThreshold = 3;
   
       { // test that optimization is run with NumericDocValues when missing 
value is NOT competitive
         final SortField sortField = new SortField("my_field", 
SortField.Type.LONG, true);
         sortField.setMissingValue(0L); // missing value is not competitive
         final Sort sort = new Sort(sortField);
         CollectorManager<TopFieldCollector, TopFieldDocs> manager =
                 TopFieldCollector.createSharedManager(sort, numHits, null, 
totalHitsThreshold);
         TopDocs topDocs = searcher.search(new MatchAllDocsQuery(), manager);
         assertEquals(topDocs.scoreDocs.length, numHits);
         assertEquals(
                 topDocs.totalHits.value,
                 numDocs); // assert that all documents were collected => 
optimization was not run
       }
   
       reader.close();
       dir.close();
     }
   ```
   
   This test shows we could not skip document by bkd,   but could use 
`NumericDocValues` to skip docs inthis RP.
   
   


-- 
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]

Reply via email to