遍历所有标签

时间:2013-06-17 13:06:50

标签: java label neo4j

我正在使用Neo4j 2.0里程碑3。

目前有这个工作代码:

String DB_PATH = "/usr/local/Cellar/neo4j/community-1.8.1-unix/libexec/data/graph.db";
GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(DB_PATH);
Transaction tx = graphDb.beginTx();
try {
  Node myNode = graphDb.createNode();
  Label myLabel = DynamicLabel.label('Label_Name');
  myNode.addLabel(myLabel);
  tx.success();
}
finally {
  tx.finish();
}

如何使用嵌入式API遍历具有Label_Name

的所有节点

1 个答案:

答案 0 :(得分:1)

退房:

GlobalGraphOperations.at(graphDb).getAllNodesWithLabel(DynamicLabel.label('Label_Name'));

http://api.neo4j.org/current/org/neo4j/tooling/GlobalGraphOperations.html#getAllNodesWithLabel(org.neo4j.graphdb.Label)