Neo4J Java API getRelationships未返回所有关系
编辑:请参阅注释并忽略此问题 我有一个带有以下代码的Neo4J插件:Neo4J Java API getRelationships未返回所有关系,java,neo4j,cypher,Java,Neo4j,Cypher,编辑:请参阅注释并忽略此问题 我有一个带有以下代码的Neo4J插件: enum VrtrackRelationshipTypes implements RelationshipType { created_for } Direction in = Direction.INCOMING; System.out.println("will get nodes created_for study with node id " + study.getId()); int count
enum VrtrackRelationshipTypes implements RelationshipType { created_for }
Direction in = Direction.INCOMING;
System.out.println("will get nodes created_for study with node id " + study.getId());
int count = 0;
for (Relationship slRel: study.getRelationships(VrtrackRelationshipTypes.created_for, in)) {
count++;
}
System.out.println(count);
返回:
将为节点id为1453769的研究创建节点
3445
但是,使用web前端和一些密码:
match (n)-[:created_for]->(m) where id(m) = 1453769 return count(distinct(n))
返回:
3631
这怎么可能呢?在一个地方,你计算了所有的关系,在另一个地方,你计算了不同的结束节点 尝试运行此操作并查看其返回的内容:
match (n)-[r:created_for]->(m)
where id(m) = 1453769
return count(*) as paths, count(r) as rels,
count(n) as seen_n, count(distinct n) as distinct_n
原来这是我自己的错误。上面的java代码片段是实际代码的简化版本,实际上循环被错误中断,导致计数太短