Reputation: 4062
StatementResult result = graphBasicService.readStatement(query);
while (result.hasNext())
{
Record record = result.next();
// Values can be extracted from a record by index or name.
System.out.println("nodes: "+record.asMap().values());
}
As In above code example I am trying to retrieve node that has values {mobile, status} . Though on browser I get List, with above code I just get one value.(One mobile number).
More on I get results printed as
mobile: [node<9>]
What does 9 denotes here? And how I can retrieve list of nodes to print mobile number.
In case you require query:
MATCH (n :User {mobile:"9999999"}) -[r :CONTACT] -> (m :User {withm:"true"}) - [r2:CONTACT] -> (n) return m
Note: graphBasicService is my custom method that executes above query.
Question Summary: I am trying to retrieve and print List of Nodes, and am unable to do so.
Upvotes: 0
Views: 1352
Reputation: 115
Instead of parsing record by record, you can get all the data using list() at once and then process it.
List<Record> recordList = result.list();
for (Record record : recordList) {
//Parsing code here
}
Refer this: https://neo4j.com/docs/api/java-driver/1.0/org/neo4j/driver/v1/StatementResult.html#list--
Upvotes: 0
Reputation: 30417
I don't see any lists here. There's no collect()
in your query, or any other function or procedure that would produce a list. You're just getting a stream of result records.
You'll get one node per record with this query, so if you want a list, you would either create a list outside the loop and add the node to the list within your loop, or, if you want to modify the query itself, use RETURN collect(m) as users
(or, if you just want the numbers, RETURN collect(m.mobile)
. If you did this, then you would get a single record back with a list of nodes (or mobile numbers).
Upvotes: 1