Search in sources :

Example 11 with FindContentByQueryResult

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);
}
Also used : FunctionExpr(com.enonic.xp.query.expr.FunctionExpr) ContentQuery(com.enonic.xp.content.ContentQuery) DynamicConstraintExpr(com.enonic.xp.query.expr.DynamicConstraintExpr) Content(com.enonic.xp.content.Content) FindContentByQueryResult(com.enonic.xp.content.FindContentByQueryResult) OrderExpr(com.enonic.xp.query.expr.OrderExpr) FieldOrderExpr(com.enonic.xp.query.expr.FieldOrderExpr) Test(org.junit.jupiter.api.Test)

Aggregations

FindContentByQueryResult (com.enonic.xp.content.FindContentByQueryResult)11 Test (org.junit.jupiter.api.Test)9 ContentQuery (com.enonic.xp.content.ContentQuery)4 Content (com.enonic.xp.content.Content)3 DynamicConstraintExpr (com.enonic.xp.query.expr.DynamicConstraintExpr)2 FieldOrderExpr (com.enonic.xp.query.expr.FieldOrderExpr)2 FunctionExpr (com.enonic.xp.query.expr.FunctionExpr)2 OrderExpr (com.enonic.xp.query.expr.OrderExpr)2 ContentId (com.enonic.xp.content.ContentId)1 ContentIds (com.enonic.xp.content.ContentIds)1 Contents (com.enonic.xp.content.Contents)1 FindContentByQueryParams (com.enonic.xp.content.FindContentByQueryParams)1 PropertySet (com.enonic.xp.data.PropertySet)1 PropertyTree (com.enonic.xp.data.PropertyTree)1 HighlightedProperties (com.enonic.xp.highlight.HighlightedProperties)1 FindNodesByQueryResult (com.enonic.xp.node.FindNodesByQueryResult)1 NodeHit (com.enonic.xp.node.NodeHit)1 NodeIds (com.enonic.xp.node.NodeIds)1 NodeQuery (com.enonic.xp.node.NodeQuery)1 Nodes (com.enonic.xp.node.Nodes)1