use of com.enonic.xp.query.aggregation.GeoDistanceAggregationQuery in project xp by enonic.
the class ContentQueryTest method createTestQuery.
private ContentQuery createTestQuery() {
final GeoDistanceAggregationQuery query1 = GeoDistanceAggregationQuery.create("geo").unit("inch").origin(GeoPoint.from("20,30")).build();
final GeoDistanceAggregationQuery query2 = GeoDistanceAggregationQuery.create("geo").unit("inch").origin(GeoPoint.from("20,30")).build();
final GeoDistanceAggregationQuery query3 = GeoDistanceAggregationQuery.create("geo").unit("inch").origin(GeoPoint.from("20,30")).build();
final HighlightQuery highlightQuery = HighlightQuery.create().property(HighlightQueryProperty.create("propertyToHighlight").build()).settings(HighlightQuerySettings.create().encoder(Encoder.HTML).fragmenter(Fragmenter.SIMPLE).fragmentSize(1).noMatchSize(2).numOfFragments(3).order(Order.SCORE).addPreTags(List.of("<a>", "<b>")).addPostTags(List.of("<c>", "<d>")).requireFieldMatch(true).tagsSchema(TagsSchema.STYLED).build()).build();
final ContentQuery.Builder builder = ContentQuery.create();
builder.addContentTypeName(ContentTypeName.imageMedia());
builder.addContentTypeNames(ContentTypeNames.from(ContentTypeName.archiveMedia(), ContentTypeName.dataMedia()));
builder.aggregationQuery(query1);
builder.aggregationQueries(Arrays.asList(query2, query3));
builder.highlight(highlightQuery);
builder.from(10);
builder.size(10);
builder.queryExpr(QueryExpr.from(CompareExpr.eq(FieldExpr.from("name"), ValueExpr.string("testerson"))));
builder.queryFilter(RangeFilter.create().from(ValueFactory.newDouble(2.0)).to(ValueFactory.newDouble(10.0)).build());
return builder.build();
}
Aggregations