use of com.enonic.xp.content.ContentQuery in project xp by enonic.
the class ContentServiceImplTest_find method dsl_query_geo_point.
@Test
public void dsl_query_geo_point() throws Exception {
PropertyTree data = createPropertyTreeForAllInputTypes();
final Content content = this.contentService.create(CreateContentParams.create().type(ContentTypeName.folder()).contentData(data).name("myContent").parent(ContentPath.ROOT).displayName("my display-name").build());
final Content child2 = createContent(ContentPath.ROOT, "c");
final PropertyTree request = new PropertyTree();
final PropertySet fulltext = request.addSet("term");
fulltext.addString("field", "data.geoPoint");
fulltext.addString("value", "59.91273,10.74609");
final ContentQuery queryDsl = ContentQuery.create().queryExpr(QueryExpr.from(DslExpr.from(request))).build();
assertEquals(1, contentService.find(FindContentByQueryParams.create().contentQuery(queryDsl).build()).getHits());
}
use of com.enonic.xp.content.ContentQuery in project xp by enonic.
the class ContentServiceImplTest_find method dsl_query_range.
@Test
public void dsl_query_range() throws Exception {
final Content site = createContent(ContentPath.ROOT, "a");
final Content child3 = createContent(site.getPath(), "d");
final Content child2 = createContent(site.getPath(), "c");
final Content child1 = createContent(site.getPath(), "b");
final PropertyTree request = new PropertyTree();
final PropertySet like = new PropertySet();
request.addSet("like", like);
like.addString("field", "_path");
like.addString("value", "*a/*");
PropertyTree order = new PropertyTree();
order.addString("field", "displayName");
order.addString("direction", "DESC");
ContentQuery queryDsl = ContentQuery.create().queryExpr(QueryExpr.from(DslExpr.from(request), DslOrderExpr.from(order))).build();
assertOrder(contentService.find(FindContentByQueryParams.create().contentQuery(queryDsl).build()), child3, child2, child1);
order = new PropertyTree();
order.addString("field", "displayName");
queryDsl = ContentQuery.create().queryExpr(QueryExpr.from(DslExpr.from(request), DslOrderExpr.from(order))).build();
assertOrder(contentService.find(FindContentByQueryParams.create().contentQuery(queryDsl).build()), child1, child2, child3);
}
use of com.enonic.xp.content.ContentQuery in project xp by enonic.
the class ContentServiceImplTest_find method dsl_query_two_root_properties.
@Test
public void dsl_query_two_root_properties() throws Exception {
final PropertyTree request = new PropertyTree();
request.addSet("fulltext", new PropertySet());
request.addSet("ngram", new PropertySet());
final ContentQuery queryDsl = ContentQuery.create().queryExpr(QueryExpr.from(DslExpr.from(request))).build();
assertThrows(IllegalArgumentException.class, () -> contentService.find(FindContentByQueryParams.create().contentQuery(queryDsl).build()));
}
use of com.enonic.xp.content.ContentQuery in project xp by enonic.
the class ContentServiceImplTest_find method dsl_query_sort.
@Test
public void dsl_query_sort() throws Exception {
final Content site = createContent(ContentPath.ROOT, "a");
final Content child3 = createContent(site.getPath(), "d");
final Content child2 = createContent(site.getPath(), "c");
final Content child1 = createContent(site.getPath(), "b");
final PropertyTree request = new PropertyTree();
final PropertySet like = new PropertySet();
request.addSet("like", like);
like.addString("field", "_path");
like.addString("value", "*a/*");
PropertyTree order = new PropertyTree();
order.addString("field", "displayName");
order.addString("direction", "DESC");
ContentQuery queryDsl = ContentQuery.create().queryExpr(QueryExpr.from(DslExpr.from(request), DslOrderExpr.from(order))).build();
assertOrder(contentService.find(FindContentByQueryParams.create().contentQuery(queryDsl).build()), child3, child2, child1);
order = new PropertyTree();
order.addString("field", "displayName");
queryDsl = ContentQuery.create().queryExpr(QueryExpr.from(DslExpr.from(request), DslOrderExpr.from(order))).build();
assertOrder(contentService.find(FindContentByQueryParams.create().contentQuery(queryDsl).build()), child1, child2, child3);
}
use of com.enonic.xp.content.ContentQuery in project xp by enonic.
the class ContentServiceImplTest_find method dsl_query_empty.
@Test
public void dsl_query_empty() throws Exception {
final ContentQuery queryDsl = ContentQuery.create().queryExpr(QueryExpr.from(DslExpr.from(new PropertyTree()))).build();
assertThrows(IllegalArgumentException.class, () -> contentService.find(FindContentByQueryParams.create().contentQuery(queryDsl).build()));
}
Aggregations