use of com.b2international.index.aggregations.AggregationBuilder 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());
}
}
Aggregations