Skip to content

Commit dbfd26e

Browse files
committed
try to avoid second search/full scan
in searchIndex
1 parent 189e6a3 commit dbfd26e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/search/SearchEngine.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,12 @@ private void searchIndex(IndexSearcher searcher, boolean paging) throws IOExcept
212212
stat.report(LOGGER, Level.FINEST, "search via SearchEngine done",
213213
"search.latency", new String[]{"category", "engine",
214214
"outcome", totalHits > 0 ? "success" : "empty"});
215-
if (!paging && totalHits > 0) {
215+
if (!paging && totalHits > hitsPerPage * cachePages) {
216216
collectorManager = new TopScoreDocCollectorManager(totalHits, Short.MAX_VALUE);
217217
hits = searcher.search(query, collectorManager).scoreDocs;
218+
stat.report(LOGGER, Level.FINEST, "FULL search via SearchEngine done",
219+
"search.latency", new String[]{"category", "engine",
220+
"outcome", totalHits > 0 ? "success" : "empty"});
218221
}
219222
StoredFields storedFields = searcher.storedFields();
220223
for (ScoreDoc hit : hits) {

0 commit comments

Comments
 (0)