use of com.b2international.index.Searcher in project snow-owl by b2ihealthcare.
the class RevisionIndexReadRequest method execute.
@Override
public B execute(final BranchContext context) {
final String branchPath = context.path();
RevisionIndex index = context.service(RevisionIndex.class);
if (snapshot) {
return index.read(branchPath, searcher -> {
try {
return next(context.inject().bind(RevisionSearcher.class, searcher).build());
} catch (QueryParseException e) {
throw new IllegalQueryParameterException(e.getMessage());
}
});
} else {
return next(context.inject().bind(RevisionSearcher.class, new RevisionSearcher() {
@Override
public <T> Aggregation<T> aggregate(AggregationBuilder<T> aggregation) throws IOException {
return index.read(branchPath, searcher -> searcher.aggregate(aggregation));
}
@Override
public Searcher searcher() {
return index.read(branchPath, searcher -> searcher.searcher());
}
@Override
public <T> Hits<T> search(Query<T> query) throws IOException {
return index.read(branchPath, searcher -> searcher.search(query));
}
@Override
public <T> Iterable<T> get(Class<T> type, Iterable<String> keys) throws IOException {
return index.read(branchPath, searcher -> searcher.get(type, keys));
}
@Override
public <T> T get(Class<T> type, String key) throws IOException {
return index.read(branchPath, searcher -> searcher.get(type, key));
}
@Override
public String branch() {
return branchPath;
}
}).build());
}
}
use of com.b2international.index.Searcher in project snow-owl by b2ihealthcare.
the class SearchIndexResourceRequest method doExecute.
@Override
protected final B doExecute(C context) throws IOException {
final Searcher searcher = searcher(context);
final Expression where = prepareQuery(context);
// configure additional fields to load when subsetting the response
List<String> fields = fields();
if (!fields().isEmpty()) {
fields = configureFieldsToLoad(fields);
}
final Hits<D> hits = searcher.search(Query.select(getSelect()).from(getFrom()).fields(fields).where(where).searchAfter(searchAfter()).limit(limit()).sortBy(querySortBy(context)).withScores(trackScores()).cached(cacheHits(context)).build());
return toCollectionResource(context, hits);
}
Aggregations