操作
- 节点的操作
- 创建节点
Node node1=graphdb.createNode();
- 节点添加属性
node1.setProperty("message", "Hello");
- 获取属性
node1.getProperty("message");
- 节点删除
node1.delete()
- 创建节点
- 关系的操作
- 创建
relationship = node1.createRelationshipTo(node2, RelTypes.KNOWS);
- 添加属性
relationship.setProperty("message", "brave neo4j");
- 创建
Cypher
ExecutionEngine engine = new ExecutionEngine(graphdb); //构造引擎
ExecutionResult result = engine.execute("start n=node(1) return n,n.message"); //执行cypher语句
返回结果如下:
- 模板如下
package testn