Neo4j 使用cypher执行索引匹配查找

Neo4j 使用cypher执行索引匹配查找,neo4j,cypher,Neo4j,Cypher,我有一个密集节点问题,为了解决这个问题,我一直在使用索引来使用本机JavaAPI执行一些匹配,但我一直在给Cypher第二次检查,并想知道这是否可以做到。目前,我的模式在Java代码中看起来像这样: Node startNode = db.getNodeById(1); Index<Relationship> relationshipIndex = db.index.forRelationships("relationships"); for(Relationship relati

我有一个密集节点问题,为了解决这个问题,我一直在使用索引来使用本机JavaAPI执行一些匹配,但我一直在给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
    }
}

我真的看不到任何地方可以只获取一个关系,然后通过这样的关系获取结束节点。

是的,在2.0中有startNode(rel)/endNode(rel)函数,但在1.9或更早版本中没有

所以理论上你可以这样做:

start rel=rel:rel_auto_index(indexKey="value") 
with endNode(rel) as n
match n-->m
return *

这将避免触及关系的startNode(除非有一个指针从
n
返回到它)。

您能在开始之外进行索引查找吗?我已经更新了我的代码来说明我的意思,但是我对第一部分进行了遍历,然后是关系索引查找。显然不是。这实际上是一个功能要求:这就是我假设的,我再次更新了这个问题,以在Cypher中反映出我想要什么,但看起来公开问题也需要我所要求的。
start rel=rel:rel_auto_index(indexKey="value") 
with endNode(rel) as n
match n-->m
return *