diff --git a/ua/org.eclipse.help.base/preferences.ini b/ua/org.eclipse.help.base/preferences.ini index 9202c2d6f28..c5c16e99bb0 100644 --- a/ua/org.eclipse.help.base/preferences.ini +++ b/ua/org.eclipse.help.base/preferences.ini @@ -207,6 +207,12 @@ maxConnections=10 # Example: maxTopics= maxTopics=500 +# Max number of topics to be searched for before filtering is applied +# If the number is too small, hits may be missed when searching e.g. in a topic and its subtopics +# The higher the number, the slightly worse the performance +# Assign a value greater than maxTopics (see above), but no greater than Integer.MAX_VALUE +maxHitsBeforeFiltering=1000 + ######################### # Search Results ######################### diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java index 18d59efd843..9977325be92 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java @@ -92,6 +92,9 @@ */ public class SearchIndex implements IHelpSearchIndex { + private static final int MAX_HITS_BEFORE_FILTERING = Platform.getPreferencesService() + .getInt(HelpBasePlugin.PLUGIN_ID, "maxHitsBeforeFiltering", 1_000, null); //$NON-NLS-1$ + private IndexReader ir; private IndexWriter iw; @@ -662,7 +665,7 @@ public void search(ISearchQuery searchQuery, ISearchHitCollector collector) thro } if (luceneQuery == null) return; - TopDocs topDocs = searcher.search(luceneQuery, 1000); + TopDocs topDocs = searcher.search(luceneQuery, MAX_HITS_BEFORE_FILTERING); collector.addHits(LocalSearchManager.asList(topDocs, searcher), queryBuilder.gethighlightTerms()); } catch (IndexSearcher.TooManyClauses tmc) { collector.addQTCException(new QueryTooComplexException());