1

给定以下代码:

public class Foo
{

     public void go(String relationship)
     {
             RestGraphDatabase rest = new RestGraphDatabase(
            prop.getProperty("address"), prop.getProperty("username"),
            prop.getProperty("password"));
             ExecutionEngine engine = new ExecutionEngine(rest,
            StringLogger.SYSTEM);
             ExecutionResult result = engine
                .execute("start n=node(7,8,9)  match(n)-[" + relationship
                        + "]->(x) return n,x,caution");    
                    scala.collection.Iterator<Node> nodes = result.columnAs("n");                
     }
}

上面的工作并允许我迭代我的列但是:

public class Foo
{

     public void go(String relationship)
     {
             RestGraphDatabase rest = new RestGraphDatabase(
            prop.getProperty("address"), prop.getProperty("username"),
            prop.getProperty("password"));
             ExecutionEngine engine = new ExecutionEngine(rest,
            StringLogger.SYSTEM);
             ExecutionResult result = engine
                .execute("start n=node(*)  match(n)-[" + relationship
                        + "]->(x) return n,x,caution");    
                    scala.collection.Iterator<Node> nodes = result.columnAs("n");                
     }
}

导致迭代器抛出不受支持的异常。node(*)列出值不是语法糖吗?如果不是,我该如何node(*)迭代它?

堆:

2013-02-18 03:13:22.227+0000 信息 [org.neo4j]: 开始 n=node(*) 匹配 (n)-[警告]->(x) 返回 n,x,警告列表 (n, x ,注意)

org.neo4j.rest.graphdb.RestGraphDatabase.getNodeManager(RestGraphDatabase.java:33) 的 org.neo4j.rest.graphdb.AbstractRemoteDatabase.getNodeManager(AbstractRemoteDatabase.java:136) 的线程“main”java.lang.UnsupportedOperationException org.neo4j.tooling.GlobalGraphOperations.(GlobalGraphOperations.java:39) 在 org.neo4j.tooling.GlobalGraphOperations.at(GlobalGraphOperations.java:51) 在 org.neo4j.cypher.internal.executionplan.builders.GraphGlobalStartBuilder$$anonfun$ createStartPipe$1.apply(GraphGlobalStartBuilder.scala:51) at org.neo4j.cypher.internal.executionplan.builders.GraphGlobalStartBuilder$$anonfun$createStartPipe$1.apply(GraphGlobalStartBuilder.scala:51) at org.neo4j.cypher.internal.pipes .StartPipe$$anonfun$createResults$1.apply(StartPipe.scala:36) 在 org.neo4j。cypher.internal.pipes.StartPipe$$anonfun$createResults$1.apply(StartPipe.scala:35) at scala.collection.Iterator$$anon$13.hasNext(Iterator.scala:371) at scala.collection.Iterator$$anon $13.hasNext(Iterator.scala:371) at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:327) at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:327) at org .neo4j.cypher.internal.ClosingIterator$$anonfun$hasNext$1.apply$mcZ$sp(ClosingIterator.scala:36) at org.neo4j.cypher.internal.ClosingIterator$$anonfun$hasNext$1.apply(ClosingIterator.scala: 35) 在 org.neo4j.cypher.internal.ClosingIterator.failIfThrows(ClosingIterator.scala:87) 在 org.neo4j 的 org.neo4j.cypher.internal.ClosingIterator$$anonfun$hasNext$1.apply(ClosingIterator.scala:35) .cypher.internal.ClosingIterator.hasNext(ClosingIterator.scala:35)在 org.neo4j.cypher.PipeExecutionResult.hasNext(PipeExecutionResult.scala:139) 在 scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:327) 在 scala.collection.Iterator$class.isEmpty(Iterator .scala:256) 在 scala.collection.AbstractIterator.isEmpty(Iterator.scala:1156)

4

2 回答 2

0

使用 RestCypherQueryEngine,请参阅此 stackoverflow 帖子。如果您查看源代码,似乎有很多不支持:AbstractRemoteDatabase。;-)

于 2013-02-18T19:28:05.247 回答
0

这个查询的实际目标是什么?这会返回您的整个图表?

如果您想对数据做一些事情,请服务器端的查询中进行,而不是通过网络拉取数据。

您的查询中也没有名为“警告”的标识符。

start n=node(*)  
match(n)-[" + relationship + "]->(x) 
return n,x,caution
于 2013-02-20T07:16:28.687 回答