Cypher output

28 views
Skip to first unread message

M.Alipour

unread,
May 29, 2012, 10:44:31 PM5/29/12
to Neo4j
Hi,
I use this code in Cypher:

String qq="start n=node("+id+") match p=(n)-[?*]->(n) return p";
ExecutionEngine engine = new ExecutionEngine( graphDb );
ExecutionResult result = engine.execute(qq);
System.out.print("\n"+result.dumpToString());

and after running, i get:

+--------+
| p |
+--------+
| <null> |
+--------+
1 row, 1 ms

my problem: how can i handle returned value in this output? What is
the type of the Cypher output?Is table? Is string? or .... How i can
process Cypher output?
for example, i want this Pseudocode:

if output==Null then print "output is null"
if output=="myOutput" print "ok"

Thanks.

Luanne Coutinho

unread,
May 29, 2012, 10:58:33 PM5/29/12
to ne...@googlegroups.com
result.iterator() will give you an iterator of type Map<String,Object> where each map represents a "row"- the String is the column name and value is the column value (p in your case).
If you just want the results of a single column, you can do result.columnAs("p") which, in your case will give you an Iterator<Node>.

-Luanne

Michael Hunger

unread,
May 30, 2012, 2:15:31 AM5/30/12
to ne...@googlegroups.com
Please use parameters (for input variables) and reuse the execution-engine. (see: http://docs.neo4j.org/chunked/milestone/cypher-parameters.html)

You could have also found the basic usage in the manual: http://docs.neo4j.org/chunked/milestone/tutorials-cypher-java.html

Michael
Reply all
Reply to author
Forward
0 new messages