use of com.enonic.xp.content.FindContentByQueryResult in project xp by enonic.
the class ContentServiceImplTest_selectorSearch method fulltext_order.
@Test
public void fulltext_order() throws Exception {
final Content site1 = createContent(ContentPath.ROOT, "site1");
final Content third = createContent(site1.getPath(), "Fisk ost");
final Content second = createContent(site1.getPath(), "Fisk ost ost");
final Content first = createContent(site1.getPath(), "Fisk ost ost ost");
final FunctionExpr fulltext = FunctionExpr.from("fulltext", ValueExpr.string("displayName"), ValueExpr.string("ost"));
final OrderExpr order = FieldOrderExpr.create(IndexPath.from("_score"), OrderExpr.Direction.DESC);
final ContentQuery query = ContentQuery.create().queryExpr(QueryExpr.from(new DynamicConstraintExpr(fulltext), order)).build();
final FindContentByQueryResult result = contentService.find(FindContentByQueryParams.create().contentQuery(query).build());
assertOrder(result, first, second, third);
}
Aggregations