Search in sources :

Example 6 with HighlightQuery

use of com.enonic.xp.query.highlight.HighlightQuery in project xp by enonic.

the class QueryContentHandler method doExecute.

@Override
protected Object doExecute() {
    final int start = valueOrDefault(this.start, 0);
    final int count = valueOrDefault(this.count, GetChildContentHandler.DEFAULT_COUNT);
    final ContentTypeNames contentTypeNames = getContentTypeNames();
    final QueryExpr queryExpr = QueryExpr.from(buildConstraintExpr(), buildOrderExpr());
    final Filters filters = JsonToFilterMapper.create(this.filters);
    final Set<AggregationQuery> aggregations = new QueryAggregationParams().getAggregations(this.aggregations);
    final HighlightQuery highlight = new QueryHighlightParams().getHighlightQuery(this.highlight);
    final ContentQuery.Builder queryBuilder = ContentQuery.create().from(start).size(count).aggregationQueries(aggregations).highlight(highlight).addContentTypeNames(contentTypeNames).queryExpr(queryExpr);
    for (final Filter filter : filters) {
        queryBuilder.queryFilter(filter);
    }
    final FindContentIdsByQueryResult queryResult = contentService.find(queryBuilder.build());
    return convert(queryResult);
}
Also used : AggregationQuery(com.enonic.xp.query.aggregation.AggregationQuery) FindContentIdsByQueryResult(com.enonic.xp.content.FindContentIdsByQueryResult) QueryExpr(com.enonic.xp.query.expr.QueryExpr) Filters(com.enonic.xp.query.filter.Filters) ContentQuery(com.enonic.xp.content.ContentQuery) Filter(com.enonic.xp.query.filter.Filter) ContentTypeNames(com.enonic.xp.schema.content.ContentTypeNames) HighlightQuery(com.enonic.xp.query.highlight.HighlightQuery)

Example 7 with HighlightQuery

use of com.enonic.xp.query.highlight.HighlightQuery in project xp by enonic.

the class AbstractFindNodesQueryHandler method createNodeQuery.

NodeQuery createNodeQuery() {
    final int start = valueOrDefault(this.start, 0);
    final int count = valueOrDefault(this.count, 10);
    final QueryExpr queryExpr = QueryExpr.from(buildConstraintExpr(), buildOrderExpr());
    final Filters filters = JsonToFilterMapper.create(this.filters);
    final AggregationQueries aggregations = new QueryAggregationParams().getAggregations(this.aggregations);
    final SuggestionQueries suggestions = new QuerySuggestionParams().getSuggestions(this.suggestions);
    final HighlightQuery highlight = new QueryHighlightParams().getHighlightQuery(this.highlight);
    return NodeQuery.create().from(start).size(count).addAggregationQueries(aggregations).addSuggestionQueries(suggestions).highlight(highlight).query(queryExpr).addQueryFilters(filters).explain(this.explain).build();
}
Also used : SuggestionQueries(com.enonic.xp.query.suggester.SuggestionQueries) Filters(com.enonic.xp.query.filter.Filters) QueryExpr(com.enonic.xp.query.expr.QueryExpr) AggregationQueries(com.enonic.xp.query.aggregation.AggregationQueries) HighlightQuery(com.enonic.xp.query.highlight.HighlightQuery)

Aggregations

HighlightQuery (com.enonic.xp.query.highlight.HighlightQuery)7 ContentQuery (com.enonic.xp.content.ContentQuery)2 QueryExpr (com.enonic.xp.query.expr.QueryExpr)2 Filters (com.enonic.xp.query.filter.Filters)2 HighlightQueryProperty (com.enonic.xp.query.highlight.HighlightQueryProperty)2 HighlightQuerySettings (com.enonic.xp.query.highlight.HighlightQuerySettings)2 ElasticHighlightQuery (com.enonic.xp.repo.impl.elasticsearch.query.ElasticHighlightQuery)2 Map (java.util.Map)2 Test (org.junit.jupiter.api.Test)2 FindContentIdsByQueryResult (com.enonic.xp.content.FindContentIdsByQueryResult)1 AggregationQueries (com.enonic.xp.query.aggregation.AggregationQueries)1 AggregationQuery (com.enonic.xp.query.aggregation.AggregationQuery)1 GeoDistanceAggregationQuery (com.enonic.xp.query.aggregation.GeoDistanceAggregationQuery)1 Filter (com.enonic.xp.query.filter.Filter)1 SuggestionQueries (com.enonic.xp.query.suggester.SuggestionQueries)1 ContentTypeNames (com.enonic.xp.schema.content.ContentTypeNames)1 HighlightBuilder (org.elasticsearch.search.highlight.HighlightBuilder)1