我有一些意外失败的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 ^"}]}
答案 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是否可行。