JRedisGraph Iterations

Hi guys,
I’m trying to execute this query in Java application.

ResultSet resultSet = graph.query(“Usergraph”, “MATCH (n:User)<-[:provider*]-(f:User)WHERE n.userid=7 RETURN collect(f)”);
its returning
results=[Record{values=[
[Node{labels=[User], id=3, propertyMap={providerid=Property{name=‘providerid’, value=2}, level=Property{name=‘level’, value=3}, userid=Property{name=‘userid’, value=4}, name=Property{name=‘name’, value=Ravi}, id=Property{name=‘id’, value=4}}},
Node{labels=[User], id=1, propertyMap={providerid=Property{name=‘providerid’, value=1}, level=Property{name=‘level’, value=4}, userid=Property{name=‘userid’, value=2}, name=Property{name=‘name’, value=Natraj}, id=Property{name=‘id’, value=2}}},
Node{labels=[User], id=0, propertyMap={providerid=Property{name=‘providerid’, value=0}, level=Property{name=‘level’, value=5}, userid=Property{name=‘userid’, value=1}, name=Property{name=‘name’, value=Ram}, id=Property{name=‘id’, value=1}}}]]}]}

Now what method i should use to get each node seperately in java.

if it returns one node im using the below iteration

resultSet = graph.query(“social”, “MATCH p = (:person)-[:knows]->(:person) RETURN p”);
while(resultSet.hasNext()) {
Record record = resultSet.next();
Path p = record.getValue(“p”);
// More path API at Javadoc.
System.out.println(p.nodeCount());
}

For Multiple node What i need to use.
Thanks in Advance

The Collect clause aggregates the results into an array and returns the array. In JRedisGraph we return the array as a List

    private List<Object> deserializeArray(Object rawScalarData) {
        List<List<Object>> array = (List<List<Object>>) rawScalarData;
        List<Object> res = new ArrayList<>(array.size());
        for (List<Object> arrayValue : array) {
            res.add(deserializeScalar(arrayValue));
        }
        return res;
    }

In this case, each record in the results set will hold a single List so you can use Java’s native List API and get each element from the list.