我有一个密集节点问题,为了解决这个问题,我一直在使用索引来使用本机 Java API 执行一些匹配,但我一直在给 Cypher 再看一眼,想知道这是否可以完成。目前我的模式在 Java 代码中看起来像这样:
Node startNode = db.getNodeById(1);
Index<Relationship> relationshipIndex = db.index.forRelationships("relationships");
for(Relationship relationship1 : startNode.getRelationships(Direction.OUT)) {
Node otherNode = relationship.getOtherNode(startNode);
String indexValue = (String)otherNode.getProperty("indexValue");
for(Relationship relationship2 : relationshipIndex.get("indexKey", indexValue)){
Node endNode = relationship.getOtherNode(startNode);
//Processing on the endNode
}
}
我如何将其翻译成密码?就像是:
START startNode=node(1)
MATCH startNode-[r1]->otherNode
WITH node:relationships("indexValue:" + otherNode.indexValue) as r2
RETURN r2.endNode //Notation for getting node off relationship?
我真的没有看到任何地方只是获得关系,然后通过这样的关系获得结束节点。