use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.
the class FindNodesByQueryCommandTest_func_fulltext method fulltext_with_path.
@Test
public void fulltext_with_path() throws Exception {
final PropertyTree data = new PropertyTree();
final String path1 = "Test.Of.String.With.Path";
final String value1 = "fisk ost pølse løk";
data.setString(path1, value1);
final String path2 = "MyString.With.Path2";
final String value2 = "vif rbk lsk sif";
data.setString(path2, value2);
final Node node = createNode(CreateNodeParams.create().name("fisk ost").parent(NodePath.ROOT).data(data).indexConfigDocument(PatternIndexConfigDocument.create().analyzer(NodeConstants.DOCUMENT_INDEX_DEFAULT_ANALYZER).defaultConfig(IndexConfig.BY_TYPE).build()).build());
final NodeQuery query = NodeQuery.create().query(QueryExpr.from(new DynamicConstraintExpr(FunctionExpr.from("fulltext", ValueExpr.string(path1), ValueExpr.string("leter etter fisk"), ValueExpr.string("OR"))))).build();
final FindNodesByQueryResult result = doFindByQuery(query);
assertEquals(1, result.getNodeIds().getSize());
assertTrue(result.getNodeIds().contains(node.id()));
}
use of com.enonic.xp.node.FindNodesByQueryResult 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.node.FindNodesByQueryResult in project xp by enonic.
the class FindNodesByQueryCommandTest method queryAndAssert.
private void queryAndAssert(final String path1, final String value1, final Node node1) {
final NodeQuery query = NodeQuery.create().query(QueryExpr.from(CompareExpr.eq(FieldExpr.from(path1), ValueExpr.string(value1)))).build();
final FindNodesByQueryResult result = doFindByQuery(query);
assertEquals(1, result.getNodeIds().getSize());
assertTrue(result.getNodeIds().contains(node1.id()));
}
use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.
the class FindNodesByQueryCommandTest_arrays method compareQueryAndAssert.
private void compareQueryAndAssert(final String path1, final String value1, final NodeId nodeId) {
final NodeQuery query = NodeQuery.create().query(QueryExpr.from(CompareExpr.eq(FieldExpr.from(path1), ValueExpr.string(value1)))).build();
final FindNodesByQueryResult result = doFindByQuery(query);
assertEquals(1, result.getNodeIds().getSize());
assertTrue(result.getNodeIds().contains(nodeId));
}
use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.
the class FindNodesByQueryCommandTest_compare method compare_eq_numeric.
@Test
public void compare_eq_numeric() throws Exception {
final PropertyTree data = new PropertyTree();
data.addDouble("myDouble", 2.0);
final Node node1 = createNode(CreateNodeParams.create().name("my-node-1").parent(NodePath.ROOT).data(data).build());
final PropertyTree data2 = new PropertyTree();
data2.addString("myDouble", "2.0");
createNode(CreateNodeParams.create().name("my-node-2").parent(NodePath.ROOT).data(data2).build());
final NodeQuery query = NodeQuery.create().query(QueryExpr.from(CompareExpr.eq(FieldExpr.from("myDouble"), ValueExpr.number(2.0)))).build();
final FindNodesByQueryResult result = doFindByQuery(query);
assertEquals(1, result.getNodeIds().getSize());
assertTrue(result.getNodeIds().contains(node1.id()));
}
Aggregations