use of com.enonic.xp.repo.impl.elasticsearch.query.translator.factory.FilterBuilderFactory 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();
}
use of com.enonic.xp.repo.impl.elasticsearch.query.translator.factory.FilterBuilderFactory in project xp by enonic.
the class CopyExecutor method createQuery.
private ElasticsearchQuery createQuery() {
final IdFilter idFilter = IdFilter.create().fieldName(NodeIndexPath.ID.getPath()).values(copyRequest.getNodeIds()).build();
final QueryBuilder idFilterBuilder = new FilterBuilderFactory(new SearchQueryFieldNameResolver()).create(Filters.from(idFilter));
QueryBuilder query = QueryBuilders.matchAllQuery();
return ElasticsearchQuery.create().query(QueryBuilders.filteredQuery(query, idFilterBuilder)).addIndexName(copyRequest.getStorageSource().getStorageName().getName()).addIndexType(copyRequest.getStorageSource().getStorageType().getName()).size(copyRequest.getNodeIds().getSize()).batchSize(BATCH_SIZE).from(0).setReturnFields(ReturnFields.from(NodeIndexPath.SOURCE)).build();
}
Aggregations