Description
public void test111() throws IOException{
Directory dir = newDirectory();
IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
RandomIndexWriter indexWriter = new RandomIndexWriter(random(), dir, iwc);
Document doc;
Random random = new Random();
int count = 0;
while (count++ < 100000){
doc = new Document();
doc.add(new SortedSetDocValuesField("sortedSet", new BytesRef("a")));
doc.add(new StringField("name", String.valueOf(random.nextInt(1000000)), StringField.Store.YES));
indexWriter.addDocument(doc);
}
indexWriter.commit();
IndexReader reader = indexWriter.getReader();
IndexSearcher searcher = newSearcher(reader);
assert reader.maxDoc() == 100000;
Query query = new MatchAllDocsQuery();
Sort sort = new Sort(new SortedSetSortField("field no exist ", false));
TopDocs noSearchField = searcher.search(query, 2000);
assert noSearchField.totalHits.value == 2001;
TopDocs hasSearchField = searcher.search(query, 2000, sort);
// if the search sort field is not exist, should early terminate after Top 2000 collected?
assert hasSearchField.totalHits.value == 100000;
indexWriter.close();
reader.close();
dir.close();
}
If search sort field does not exist, should we early terminate collection after TopN collected?
Description
If search sort field does not exist, should we early terminate collection after TopN collected?