use of com.enonic.xp.repo.impl.elasticsearch.query.translator.factory.SortQueryBuilderFactory in project xp by enonic.
the class ESQueryTranslator method doTranslate.
private static ElasticsearchQuery doTranslate(final SearchRequest request, final QueryTypeTranslator queryTypeTranslator) {
final ESSource esSource = ESSourceFactory.create(request.getSearchSource());
final QueryBuilder queryBuilder = queryTypeTranslator.createQueryBuilder(esSource.getFilters());
final Query query = request.getQuery();
final Set<AbstractAggregationBuilder> aggregations = new AggregationQueryBuilderFactory(queryTypeTranslator.getFieldNameResolver()).create(query.getAggregationQueries());
final Set<SuggestBuilder.SuggestionBuilder> suggestions = new SuggestionQueryBuilderFactory(queryTypeTranslator.getFieldNameResolver()).create(query.getSuggestionQueries());
final ElasticHighlightQuery highlight = new ElasticHighlightQueryBuilderFactory().create(query.getHighlight());
final List<SortBuilder> sortBuilders = new SortQueryBuilderFactory(queryTypeTranslator.getFieldNameResolver()).create(query.getOrderBys());
final QueryBuilder filterBuilder = new FilterBuilderFactory(queryTypeTranslator.getFieldNameResolver()).create(query.getPostFilters());
return ElasticsearchQuery.create().addIndexNames(esSource.getIndexNames()).addIndexTypes(esSource.getIndexTypes()).query(queryBuilder).from(query.getFrom()).size(query.getSize()).explain(query.isExplain()).setReturnFields(request.getReturnFields()).setAggregations(aggregations).setSuggestions(suggestions).setHighlight(highlight).sortBuilders(sortBuilders).filter(filterBuilder).batchSize(queryTypeTranslator.getBatchSize()).searchMode(query.getSearchMode()).searchOptimizer(queryTypeTranslator.getSearchOptimizer()).searchPreference(request.getSearchPreference()).build();
}
Aggregations