1
votes

Given the following code:

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");                
     }
}

The above works and allows me to iterate over my columns however:

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");                
     }
}

Results in the iterator throwing an unsupported exception. Is node(*) not syntactic sugar for listing out the values? And if not how can I node(*) and iterate over it?

Stack:

2013-02-18 03:13:22.227+0000 INFO [org.neo4j]: start n=node(*) match(n)-[caution]->(x) return n,x,caution List(n, x, caution)

Exception in thread "main" java.lang.UnsupportedOperationException at org.neo4j.rest.graphdb.AbstractRemoteDatabase.getNodeManager(AbstractRemoteDatabase.java:136) at org.neo4j.rest.graphdb.RestGraphDatabase.getNodeManager(RestGraphDatabase.java:33) at org.neo4j.tooling.GlobalGraphOperations.(GlobalGraphOperations.java:39) at org.neo4j.tooling.GlobalGraphOperations.at(GlobalGraphOperations.java:51) at 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) at 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) at org.neo4j.cypher.internal.ClosingIterator$$anonfun$hasNext$1.apply(ClosingIterator.scala:35) at org.neo4j.cypher.internal.ClosingIterator.failIfThrows(ClosingIterator.scala:87) at org.neo4j.cypher.internal.ClosingIterator.hasNext(ClosingIterator.scala:35) at org.neo4j.cypher.PipeExecutionResult.hasNext(PipeExecutionResult.scala:139) at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:327) at scala.collection.Iterator$class.isEmpty(Iterator.scala:256) at scala.collection.AbstractIterator.isEmpty(Iterator.scala:1156)

2
A tstorms said, never us a ExecutionEngine around a RestGraphDatabase, use RestCypherQueryEngine or RestAPIFacade.query().Michael Hunger

2 Answers

0
votes

Use the RestCypherQueryEngine, see this stackoverflow post. Seems there's a lot not supported if you look at the source: AbstractRemoteDatabase. ;-)

0
votes

What is actually your goal with this query? This returns your whole graph?

If you want to do something with the data, do it in the query on the server side and not by pulling the data over the wire.

You also don't have an identifier named caution in your query.

start n=node(*)  
match(n)-[" + relationship + "]->(x) 
return n,x,caution