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);
}
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);
}
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()));
}
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);
}
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());
}
Aggregations