Search in sources :

Example 81 with FindNodesByQueryResult

use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.

the class FindNodesByQueryCommandTest_order method testByStringAndBooleanAndLongSorting.

@Test
public void testByStringAndBooleanAndLongSorting() {
    String[] orders = { FIELD_STRING + " " + ORDER_DESC, FIELD_BOOL + " " + ORDER_DESC, FIELD_LONG + " " + ORDER_ASC };
    FindNodesByQueryResult result = sort(orders);
    Iterator<Node> iterator = getNodes(result.getNodeIds()).iterator();
    assertEquals("node2", iterator.next().name().toString());
    assertEquals("node1", iterator.next().name().toString());
    assertEquals("node3", iterator.next().name().toString());
}
Also used : FindNodesByQueryResult(com.enonic.xp.node.FindNodesByQueryResult) Node(com.enonic.xp.node.Node) Test(org.junit.jupiter.api.Test)

Example 82 with FindNodesByQueryResult

use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.

the class FindNodesByQueryCommandTest_func_pathMatch method matches_subPath.

@Test
public void matches_subPath() throws Exception {
    createNode(CreateNodeParams.create().name("node1").parent(NodePath.ROOT).build());
    final FindNodesByQueryResult result = doQuery("pathMatch('_path', '/node1/node1_1/node1_1_1')");
    assertEquals(1, result.getNodeIds().getSize());
}
Also used : FindNodesByQueryResult(com.enonic.xp.node.FindNodesByQueryResult) Test(org.junit.jupiter.api.Test)

Example 83 with FindNodesByQueryResult

use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.

the class FindNodesByQueryCommandTest_func_pathMatch method score_order_most_matching_first.

@Test
public void score_order_most_matching_first() throws Exception {
    final Node node1 = createNode(CreateNodeParams.create().name("node1").setNodeId(NodeId.from("node1")).parent(NodePath.ROOT).build());
    final Node node1_1 = createNode(CreateNodeParams.create().name("node1_1").setNodeId(NodeId.from("node1_1")).parent(node1.path()).build());
    final Node node1_1_1 = createNode(CreateNodeParams.create().name("node1_1_1").setNodeId(NodeId.from("node1_1_1")).parent(node1_1.path()).build());
    final FindNodesByQueryResult result = doQuery("pathMatch('_path', '/node1/node1_1/node1_1_1')");
    assertOrder(result, node1_1_1, node1_1, node1);
}
Also used : FindNodesByQueryResult(com.enonic.xp.node.FindNodesByQueryResult) Node(com.enonic.xp.node.Node) Test(org.junit.jupiter.api.Test)

Example 84 with FindNodesByQueryResult

use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.

the class FindNodesByQueryCommandTest_func_pathMatch method matches_subPath_minimum_match.

@Test
public void matches_subPath_minimum_match() throws Exception {
    final Node node1 = createNode(CreateNodeParams.create().name("node1").setNodeId(NodeId.from("node1")).parent(NodePath.ROOT).build());
    final Node node1_1 = createNode(CreateNodeParams.create().name("node1_1").setNodeId(NodeId.from("node1_1")).parent(node1.path()).build());
    final Node node1_1_1 = createNode(CreateNodeParams.create().name("node1_1_1").setNodeId(NodeId.from("node1_1_1")).parent(node1_1.path()).build());
    final FindNodesByQueryResult result = doQuery("pathMatch('_path', '/node1/node1_1/node1_1_1', 2)");
    assertOrder(result, node1_1_1, node1_1);
}
Also used : FindNodesByQueryResult(com.enonic.xp.node.FindNodesByQueryResult) Node(com.enonic.xp.node.Node) Test(org.junit.jupiter.api.Test)

Aggregations

FindNodesByQueryResult (com.enonic.xp.node.FindNodesByQueryResult)84 NodeQuery (com.enonic.xp.node.NodeQuery)61 Test (org.junit.jupiter.api.Test)55 Node (com.enonic.xp.node.Node)32 BucketAggregation (com.enonic.xp.aggregation.BucketAggregation)19 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)19 Bucket (com.enonic.xp.aggregation.Bucket)14 PropertyTree (com.enonic.xp.data.PropertyTree)13 Nodes (com.enonic.xp.node.Nodes)9 DynamicConstraintExpr (com.enonic.xp.query.expr.DynamicConstraintExpr)9 Aggregation (com.enonic.xp.aggregation.Aggregation)8 Buckets (com.enonic.xp.aggregation.Buckets)6 QueryExpr (com.enonic.xp.query.expr.QueryExpr)4 DateRangeBucket (com.enonic.xp.aggregation.DateRangeBucket)3 NodeHit (com.enonic.xp.node.NodeHit)3 CompareExpr (com.enonic.xp.query.expr.CompareExpr)3 NumericRangeBucket (com.enonic.xp.aggregation.NumericRangeBucket)2 SingleValueMetricAggregation (com.enonic.xp.aggregation.SingleValueMetricAggregation)2 ContentId (com.enonic.xp.content.ContentId)2 Context (com.enonic.xp.context.Context)2