我想使用Java的Cypher Queries从neo4j数据库中删除两个节点之间的关系 下面的编程是我的代码:
ExecutionEngine engine = new ExecutionEngine( graphDb );
engine.execute( "Start n= node(*) delete n" );
但是它给出了如下错误:
Exception in thread "main" expected return clause
"Start n= node(*) delete n"
^
at org.neo4j.cypher.internal.parser.v1_7.CypherParserImpl.parse(CypherParserImpl.scala:66)
at org.neo4j.cypher.CypherParser.parse(CypherParser.scala:44)
at org.neo4j.cypher.ExecutionEngine$$anonfun$prepare$1.apply(ExecutionEngine.scala:61)
at org.neo4j.cypher.ExecutionEngine$$anonfun$prepare$1.apply(ExecutionEngine.scala:61)
at org.neo4j.cypher.internal.LRUCache.getOrElseUpdate(LRUCache.scala:31)
at org.neo4j.cypher.ExecutionEngine.prepare(ExecutionEngine.scala:61)
at org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:55)
at org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:52)
at org.neo4j.cypher.javacompat.ExecutionEngine.execute(ExecutionEngine.java:63)
但是当我尝试返回所有节点时,这个查询就是执行:
ExecutionEngine engine = new ExecutionEngine( graphDb );
engine.execute( "Start n= node(*) return n" ); this query return all node.
只有删除命令才会出现上述问题... 任何人都可以给我建议如何在java中使用Progrmming删除节点和关系。
答案 0 :(得分:0)
常见问题:如果节点仍然存在关系,Neo4j将不会删除该节点。 如果你这样做:
Start n= node(*) optional match (n)-[r]-() delete n,r
这对这种情况有帮助。