我正在使用Neo4j插件,需要按属性值检索关系。
我可以访问Neo4j GraphDatabaseService
,它有一个非常方便的方法GraphDatabaseService.findNode(Label label, String property , String value)
。
我正在寻找此方法的关系对象,例如GraphDatabaseService.findRelationship(RelationshipType type, String property , String value)
。
这是否存在?它是否在路线图上?还有另外一种方法吗?
答案 0 :(得分:1)
目前只有架构索引支持节点。
在没有周围节点的上下文的情况下,按值查找关系的用例是什么?
您可以通过Java API访问关系的手动索引,这非常好,因为您可以find relationships只通过属性,也可以在其任一端节点的上下文中。如果你创建一个index-per rel-type,它对于具有许多关系的节点来说也非常好,通过传入开始或结束节点来过滤掉一些。 这就是我在APOC程序库中添加的支持。
但您必须手动为该索引添加关系。
答案 1 :(得分:0)
总结迈克尔和克里斯托夫的答案:
要通过UUID获得关系,请输入以下代码:
public Relationship getRelByUuid(GraphDatabaseService database, String uuid) {
UuidReader reader = new DefaultUuidReader(
getStartedRuntime(database).getModule(UuidModule.class).getConfiguration(),
database
);
return database.getRelationshipById(uuidReader.getRelationshipIdByUuid(uuid));
}