Using Neo4j 2.0 milestone 3
Currently have this code (working code)
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();
tx.success();
}
finally {
tx.finish();
}
This is the embedded API. How can I add a label to my node? Thanks!
You have to create a label first by creating an Enum that implements Label, or use DynamicLabel to create one on the fly.
Once you have created, you will have to add it to the Node.
The below shows you how to do it with DynamicLabel:
import org.neo4j.graphdb.DynamicLabel;
Label myLabel = DynamicLabel.label("Label_Name");
myNode.addLabel(myLabel);
You also have to do this within a Transaction.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With