Apologies if this is a simple question, but I turn to the wisdom of SO to get me over this bump :)
I'm using RoR 3.1.1 with the neography gem.
I currently have a neo4j graph of people nodes with relationships as "friends" connecting them. Given a specific person's node, I'd like to page through results of their friends-of-friends (2nd degree nodes) 5 at a time. Right now, I use the following traversal code which gets me ALL of the friends-of-friends at once (it can take so long that it will cause a timeout):
nodes = @neo.traverse(user_node,"nodes", {"order" => "breadth first",
"uniqueness" => "node global",
"relationships" => {"type"=> "friends", "direction" => "all"},
"return filter" => {
"language" => "javascript",
"body" =>
"position.length() == 2;"},
"depth" => 2})
From the neo4j website (http://docs.neo4j.org/chunked/stable/rest-api-traverse.html#rest-api-creating-a-paged-traverser), it looks like there is already such a thing as paged traversals, but I don't see any references to doing this from neography.
Could someone provide example code to show how to do this with neography if possible, how to do it without neography if necessary, or a work-around such as limiting the number of results returned from the example traversal I'm already doing? Thanks!
Could you use a Cypher query for this, http://docs.neo4j.org/chunked/snapshot/cypher-query-lang.html, like
START n = node(0) Match n-[:friends]->()-[:friends]->fof RETURN fof SKIP 0 LIMIT 5
for the first 5 friends?