Search in sources :

Example 11 with PropertyTree

use of com.enonic.xp.data.PropertyTree in project xp by enonic.

the class FindNodesByQueryCommandTest_func_fulltext method word_delimiter_testing_dot.

@Test
public void word_delimiter_testing_dot() throws Exception {
    final PropertyTree data = new PropertyTree();
    data.addString("title", "testing.delimiter");
    createNode(CreateNodeParams.create().name("my-node-1").parent(NodePath.ROOT).data(data).indexConfigDocument(PatternIndexConfigDocument.create().analyzer(NodeConstants.DOCUMENT_INDEX_DEFAULT_ANALYZER).defaultConfig(IndexConfig.BY_TYPE).build()).build());
    queryAndAssert("fulltext('title', 'testing', 'AND')", 1);
    queryAndAssert("fulltext('title', 'delimiter', 'AND')", 1);
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) Test(org.junit.jupiter.api.Test)

Example 12 with PropertyTree

use of com.enonic.xp.data.PropertyTree in project xp by enonic.

the class FindNodesByQueryCommandTest_func_fulltext method fulltext_word_breaking_character.

@Test
public void fulltext_word_breaking_character() throws Exception {
    final PropertyTree data = new PropertyTree();
    data.addString("title", "Levenshteins-algorithm");
    createNode(CreateNodeParams.create().name("my-node-1").parent(NodePath.ROOT).data(data).indexConfigDocument(PatternIndexConfigDocument.create().analyzer(NodeConstants.DOCUMENT_INDEX_DEFAULT_ANALYZER).defaultConfig(IndexConfig.BY_TYPE).build()).build());
    queryAndAssert("fulltext('title', 'levenshteins algorithm', 'AND')", 1);
    queryAndAssert("fulltext('title', 'levenshteins-algorithm', 'AND')", 1);
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) Test(org.junit.jupiter.api.Test)

Example 13 with PropertyTree

use of com.enonic.xp.data.PropertyTree in project xp by enonic.

the class FindNodesByQueryCommandTest_func_fulltext method fulltext_norwegian_characters.

@Test
public void fulltext_norwegian_characters() throws Exception {
    final PropertyTree data = new PropertyTree();
    data.addString("myProperty", "æ");
    final PropertySet userdata = data.addSet("data");
    userdata.addString("displayName", "ø å");
    final Node node = createNode(CreateNodeParams.create().name("my-node-1").parent(NodePath.ROOT).data(data).indexConfigDocument(PatternIndexConfigDocument.create().analyzer(NodeConstants.DOCUMENT_INDEX_DEFAULT_ANALYZER).defaultConfig(IndexConfig.BY_TYPE).build()).build());
    refresh();
    printContentRepoIndex();
    final NodeQuery query = NodeQuery.create().query(QueryExpr.from(new DynamicConstraintExpr(FunctionExpr.from("fulltext", ValueExpr.string(NodeIndexPath.ALL_TEXT.getPath()), ValueExpr.string("æ"), ValueExpr.string("OR"))))).build();
    final FindNodesByQueryResult result = doFindByQuery(query);
    assertEquals(1, result.getNodeIds().getSize());
    assertTrue(result.getNodeIds().contains(node.id()));
    final NodeQuery query2 = NodeQuery.create().query(QueryExpr.from(new DynamicConstraintExpr(FunctionExpr.from("fulltext", ValueExpr.string("data.displayName"), ValueExpr.string("ø å"), ValueExpr.string("OR"))))).build();
    final FindNodesByQueryResult result2 = doFindByQuery(query2);
    assertEquals(1, result2.getNodeIds().getSize());
    assertTrue(result.getNodeIds().contains(node.id()));
}
Also used : DynamicConstraintExpr(com.enonic.xp.query.expr.DynamicConstraintExpr) FindNodesByQueryResult(com.enonic.xp.node.FindNodesByQueryResult) PropertyTree(com.enonic.xp.data.PropertyTree) Node(com.enonic.xp.node.Node) NodeQuery(com.enonic.xp.node.NodeQuery) PropertySet(com.enonic.xp.data.PropertySet) Test(org.junit.jupiter.api.Test)

Example 14 with PropertyTree

use of com.enonic.xp.data.PropertyTree in project xp by enonic.

the class FindNodesByQueryCommandTest method nested_paths.

@Test
public void nested_paths() throws Exception {
    final PropertyTree data = new PropertyTree();
    final String path1 = "test.string.with.path";
    final String value1 = "myValue";
    data.setString(path1, value1);
    final String path2 = "test.string.with.path2";
    final String value2 = "myValue2";
    data.setString(path2, value2);
    final Node node1 = createNode(CreateNodeParams.create().name("my-node-1").parent(NodePath.ROOT).data(data).build());
    createNode(CreateNodeParams.create().name("my-node-2").parent(NodePath.ROOT).build());
    createNode(CreateNodeParams.create().name("child-node").parent(node1.path()).build());
    queryAndAssert(path1, value1, node1);
    queryAndAssert(path2, value2, node1);
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) Node(com.enonic.xp.node.Node) Test(org.junit.jupiter.api.Test)

Example 15 with PropertyTree

use of com.enonic.xp.data.PropertyTree in project xp by enonic.

the class FindNodesByQueryCommandTest_arrays method nested_array_elements.

@Test
public void nested_array_elements() throws Exception {
    final PropertyTree data = new PropertyTree();
    final PropertySet cars = data.addSet("cars");
    final PropertySet car1 = cars.addSet("car");
    car1.setString("brand", "skoda");
    car1.setString("color", "artic grey");
    final PropertySet car2 = cars.addSet("car");
    car2.setString("brand", "volvo");
    car2.setString("color", "red");
    final Node node1 = createNode(CreateNodeParams.create().name("my-node-1").parent(NodePath.ROOT).data(data).indexConfigDocument(PatternIndexConfigDocument.create().analyzer(NodeConstants.DOCUMENT_INDEX_DEFAULT_ANALYZER).defaultConfig(IndexConfig.BY_TYPE).build()).build());
    printContentRepoIndex();
    compareQueryAndAssert("cars.car.brand", "skoda", node1.id());
    compareQueryAndAssert("cars.car.brand", "volvo", node1.id());
    compareQueryAndAssert("cars.car.color", "red", node1.id());
    compareQueryAndAssert("cars.car.color", "artic grey", node1.id());
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) Node(com.enonic.xp.node.Node) PropertySet(com.enonic.xp.data.PropertySet) Test(org.junit.jupiter.api.Test)

Aggregations

PropertyTree (com.enonic.xp.data.PropertyTree)660 Test (org.junit.jupiter.api.Test)405 PropertySet (com.enonic.xp.data.PropertySet)150 Content (com.enonic.xp.content.Content)126 Node (com.enonic.xp.node.Node)112 CreateContentParams (com.enonic.xp.content.CreateContentParams)64 Form (com.enonic.xp.form.Form)37 Page (com.enonic.xp.page.Page)32 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)31 DescriptorKey (com.enonic.xp.page.DescriptorKey)30 GetContentTypeParams (com.enonic.xp.schema.content.GetContentTypeParams)30 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)28 PrincipalKey (com.enonic.xp.security.PrincipalKey)28 BinaryReference (com.enonic.xp.util.BinaryReference)28 Property (com.enonic.xp.data.Property)26 UpdateContentParams (com.enonic.xp.content.UpdateContentParams)24 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)23 ByteSource (com.google.common.io.ByteSource)22 ExtraData (com.enonic.xp.content.ExtraData)21 Instant (java.time.Instant)21