Search in sources :

Example 1 with Builder

use of com.b2international.index.query.SortBy.Builder in project snow-owl by b2ihealthcare.

the class ResourceSearchRequest method toQuerySortBy.

@Override
protected void toQuerySortBy(RepositoryContext context, Builder sortBuilder, Sort sort) {
    if (sort instanceof SortField) {
        SortField sortField = (SortField) sort;
        if (ResourceSearchRequestBuilder.TYPE_RANK.equals(sortField.getField())) {
            Registry registry = context.service(ResourceTypeConverter.Registry.class);
            Map<String, Integer> orderMap = registry.getResourceTypeConverters().values().stream().collect(Collectors.toMap(typeDef -> typeDef.getResourceType(), typeDef -> typeDef.getRank()));
            sortBuilder.sortByScriptNumeric(ResourceSearchRequestBuilder.TYPE_RANK, Map.of("ranks", orderMap), sort.isAscending() ? Order.ASC : Order.DESC);
            return;
        }
    }
    super.toQuerySortBy(context, sortBuilder, sort);
}
Also used : ResourceDocument(com.b2international.snowowl.core.internal.ResourceDocument) RepositoryContext(com.b2international.snowowl.core.domain.RepositoryContext) Hits(com.b2international.index.Hits) ResourceTypeConverter(com.b2international.snowowl.core.ResourceTypeConverter) Order(com.b2international.index.query.SortBy.Order) Map(java.util.Map) Resources(com.b2international.snowowl.core.Resources) ExpressionBuilder(com.b2international.index.query.Expressions.ExpressionBuilder) Builder(com.b2international.index.query.SortBy.Builder) Registry(com.b2international.snowowl.core.ResourceTypeConverter.Registry) Collectors(java.util.stream.Collectors) ResourceTypeConverter(com.b2international.snowowl.core.ResourceTypeConverter) Registry(com.b2international.snowowl.core.ResourceTypeConverter.Registry)

Aggregations

Hits (com.b2international.index.Hits)1 ExpressionBuilder (com.b2international.index.query.Expressions.ExpressionBuilder)1 Builder (com.b2international.index.query.SortBy.Builder)1 Order (com.b2international.index.query.SortBy.Order)1 ResourceTypeConverter (com.b2international.snowowl.core.ResourceTypeConverter)1 Registry (com.b2international.snowowl.core.ResourceTypeConverter.Registry)1 Resources (com.b2international.snowowl.core.Resources)1 RepositoryContext (com.b2international.snowowl.core.domain.RepositoryContext)1 ResourceDocument (com.b2international.snowowl.core.internal.ResourceDocument)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1