Skip to content

Commit dc18b24

Browse files
howlgeriloveeclipse
authored andcommitted
Help search: Make the number of max hits before filtering configurable
In the search of the help system, make the number of topics to be searched for before the filtering is applied configurable, so that it can be set in the "plugin_customization.ini" file. If the number is too small, hits may be missed, e.g. when searching in a topic and its subtopics. The higher the number, the slightly worse the performance. The default is 1,000 and the maximum number of hits displayed to the user is 500, which means that if more than 500 of the hits before filtering are outside of the search scope, some hits will be missed. See also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=357857
1 parent 0fc54b8 commit dc18b24

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

ua/org.eclipse.help.base/preferences.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,12 @@ maxConnections=10
207207
# Example: maxTopics=
208208
maxTopics=500
209209

210+
# Max number of topics to be searched for before filtering is applied
211+
# If the number is too small, hits may be missed when searching e.g. in a topic and its subtopics
212+
# The higher the number, the slightly worse the performance
213+
# Assign a value greater than maxTopics (see above), but no greater than Integer.MAX_VALUE
214+
maxHitsBeforeFiltering=1000
215+
210216
#########################
211217
# Search Results
212218
#########################

ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@
9292
*/
9393
public class SearchIndex implements IHelpSearchIndex {
9494

95+
private static final int MAX_HITS_BEFORE_FILTERING = Platform.getPreferencesService()
96+
.getInt(HelpBasePlugin.PLUGIN_ID, "maxHitsBeforeFiltering", 1_000, null); //$NON-NLS-1$
97+
9598
private IndexReader ir;
9699

97100
private IndexWriter iw;
@@ -662,7 +665,7 @@ public void search(ISearchQuery searchQuery, ISearchHitCollector collector) thro
662665
}
663666
if (luceneQuery == null)
664667
return;
665-
TopDocs topDocs = searcher.search(luceneQuery, 1000);
668+
TopDocs topDocs = searcher.search(luceneQuery, MAX_HITS_BEFORE_FILTERING);
666669
collector.addHits(LocalSearchManager.asList(topDocs, searcher), queryBuilder.gethighlightTerms());
667670
} catch (IndexSearcher.TooManyClauses tmc) {
668671
collector.addQTCException(new QueryTooComplexException());

0 commit comments

Comments
 (0)