cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Cannot iterate through Result

bpruitt
Node Link

I cannot get a simple iteration through Nodes to work.
My query is:
String query = "MATCH (n:Concept) WHERE n.type = 'text' RETURN (n)";
When I execute:
Result qResult = db.execute(query);
System.out.println(qResult.resultAsString());
I get:
+-----------------------------------------------------------------------------------------+
| n |
+-----------------------------------------------------------------------------------------+
| Node[2]{reference:"3306c766-4c26-44a4-8112-f5fa6cb6d226",type:"text",value:"insurance"} |
| Node[3]{reference:"3306c766-4c26-44a4-8112-f5fa6cb6d226",type:"text",value:"liability"} |
+-----------------------------------------------------------------------------------------+
2 rows

Two nodes is what I expect.

When I try either:
ResourceIterator nodes = qResult.columnAs("n");
while(nodes.hasNext()) {
:
:
}

or

while(qResult.hasNext()) {
:
:
}

The loop never executes because hasNext() returns false.

What am I missing?

1 REPLY 1

bpruitt
Node Link

Well, well. Answered my own question. For some reason, I did not see
The execution result represented by this object will be consumed in its entirety after this method is called. Calling any of the other iterating methods on it should not be expected to return any results.

Even though it is in bold!

Hope, I didn't waste anyone's time.