Slide 33
Slide 33 text
static SearchResult executeSearch(QueryWithVector qwv, String indexName, ElasticsearchClient esClient) {
try (var scope = new StructuredTaskScope.ShutdownOnFailure()) {
var knnSearch = scope.fork(() -> performKnnSearch(qwv.vector(), indexName, esClient));
var classicSearch = scope.fork(() -> performClassicSearch(qwv.query(), indexName, esClient));
scope.join();
scope.throwIfFailed();
var combined = combineUsingRRF(List.of(knnSearch.get(), classicSearch.get()), 60, TOP_K);
return new SearchResult(qwv.query(), combined);
} catch (Exception e) {
throw new RuntimeException();
}
}
static SearchResult executeSearch(QueryWithVector qwv, String indexName, ElasticsearchClient esClient) {
try (var scope = StructuredTaskScope.open()) {
var knnSearch = scope.fork(() -> performKnnSearch(qwv.vector(), indexName, esClient));
var classicSearch = scope.fork(() -> performClassicSearch(qwv.query(), indexName, esClient));
scope.join();
var combined = combineUsingRRF(List.of(knnSearch.get(), classicSearch.get()), 60, TOP_K);
return new SearchResult(qwv.query(), combined);
} catch (Exception e) {
throw new RuntimeException();
}
}
Java 24
Java 25