为什么这个neo4j-ogm代码产生'无效语法'?

时间:2015-10-16 20:25:16

标签: neo4j spring-data-neo4j-4 neo4j-ogm

我有一些意外失败的spring-data-neo4j / ogm代码。

public Member loadMemberBySocialMediaAccount(String connectionKey) {
        String[] connectionKeyParts = connectionKey.split(":");
        Filters filters = new Filters()
                .add(new Filter("providerId", connectionKeyParts[0]))
                .add(new Filter("providerUserId", connectionKeyParts[1]));
        Iterator<SocialMediaAccount> socialMediaAccounts = session.loadAll(SocialMediaAccount.class, filters, 2).iterator();
        return socialMediaAccounts.hasNext() ? socialMediaAccounts.next().getMember() : null;
}

当我深入研究ogm代码时,我会看到抛出以下异常。这是预期的吗?

org.neo4j.ogm.session.result.ResultProcessingException: "errors":[{"code":"Neo.ClientError.Statement.InvalidSyntax","message":"Invalid input 'n': expected whitespace, comment, '.', node labels, '[', \"=~\", IN, IS, '^', '*', '/', '%', '+', '-', '<', '>', \"<=\", \">=\", '=', \"<>\", \"!=\", AND, XOR, OR, LOAD CSV, START, MATCH, UNWIND, MERGE, CREATE, SET, DELETE, REMOVE, FOREACH, WITH, RETURN, UNION, ';' or end of input (line 1, column 72 (offset: 71))\n\"MATCH (n:`SocialMediaAccount`) WHERE n.`providerId` = { `providerId` } n.`providerUserId` = { `providerUserId` } WITH n MATCH p=(n)-[*0..2]-(m) RETURN p, ID(n)\"\n                                                                        ^"}]}

1 个答案:

答案 0 :(得分:0)

刚检查了测试,预期的是除了第一个之外的所有过滤器都必须定义一个BooleanOperator(AND或OR)。

所以在你的情况下:

Filters filters = new Filters()
                .add(new Filter("providerId", connectionKeyParts[0]));
Filter providerUserIdFilter = new Filter("providerUserId", connectionKeyParts[1]);
providerUserIdFilter.setBooleanOperator(BooleanOperator.AND);
filters.add(providerUserIdFilter);

我已打开https://github.com/neo4j/neo4j-ogm/issues/73,以便我们确定将BooleanOperator默认为后续过滤器为AND是否可行。