Skip to content

Commit 46620d3

Browse files
howlgeriloveeclipse
authored andcommitted
Add org.eclipse.help.internal.search.SearchIndex#customSearch(...)
This adds a `customSearch` method to the internal class `org.eclipse.help.internal.search.SearchIndex`. The purpose is to be able to implement a hybrid search that combines a semantic search with a sparse keyword search. And the sparse keyword search uses the existing `SearchIndex` via this new method.
1 parent 31bb835 commit 46620d3

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import java.util.Locale;
3636
import java.util.Map;
3737
import java.util.Set;
38+
import java.util.function.BiConsumer;
3839
import java.util.zip.ZipEntry;
3940
import java.util.zip.ZipInputStream;
4041

@@ -664,6 +665,29 @@ public void search(ISearchQuery searchQuery, ISearchHitCollector collector)
664665
}
665666
}
666667

668+
/**
669+
* Performs a custom query search on this index (experimental)
670+
*/
671+
public void customSearch(BiConsumer<IndexSearcher, AnalyzerDescriptor> customSearcher) {
672+
try {
673+
if (closed)
674+
return;
675+
registerSearch(Thread.currentThread());
676+
if (closed)
677+
return;
678+
if (searcher == null) {
679+
try {
680+
openSearcher();
681+
} catch (Exception e) {
682+
ILog.of(getClass()).error("Failed to open search index. Index directory: " + indexDir, e); //$NON-NLS-1$
683+
}
684+
}
685+
customSearcher.accept(searcher, analyzerDescriptor);
686+
} finally {
687+
unregisterSearch(Thread.currentThread());
688+
}
689+
}
690+
667691
@Override
668692
public String getLocale() {
669693
return locale;

0 commit comments

Comments
 (0)