Exemple #1
0
  protected Node createNode(final NodePath parentPath, final String name) {
    final PropertyTree data = new PropertyTree();
    data.setString("displayName", "This is brand new node");
    final PropertySet someData = data.addSet("someData");
    someData.setString("cars", "skoda");
    someData.addString("cars", "tesla model x");
    someData.setString("likes", "plywood");
    someData.setLong("numberOfUselessGadgets", 123L);

    final PatternIndexConfigDocument indexConfig =
        PatternIndexConfigDocument.create()
            .defaultConfig(IndexConfig.MINIMAL)
            .add("displayName", IndexConfig.FULLTEXT)
            .build();

    return Node.create()
        .id(NodeId.from("nodeId"))
        .parentPath(parentPath)
        .name(name)
        .data(data)
        .indexConfigDocument(indexConfig)
        .permissions(
            AccessControlList.create()
                .add(
                    AccessControlEntry.create()
                        .principal(PrincipalKey.ofRole("admin"))
                        .allowAll()
                        .build())
                .build())
        .nodeState(NodeState.DEFAULT)
        .nodeVersionId(NodeVersionId.from("versionKey"))
        .timestamp(Instant.parse("2010-10-10T10:10:10.10Z"))
        .build();
  }
  @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.getNodes().getSize());
    assertNotNull(result.getNodes().getNodeById(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.getNodes().getSize());
    assertNotNull(result2.getNodes().getNodeById(node.id()));
  }