Hi All,
when using java for embedded queries and you return paths there doesn't
seem to be an iterator type available to help extract node or properties
from paths.
e.g. for the sample code below - I can get the nodes out if I apply some
heavy handed manual string manipulation but it is a real pain and not
scalable.
Any guidance on how to get discrete node & relationship, IDs, names and
properties extracted etc is greatly appreciated.
Is anyone aware of some good examples in this area?
Regards, John.
*Example Java - that needs modifying*:
ExecutionResult result;
try ( Transaction ignored = db.beginTx() )
{
result = engine.execute( "---query in returns paths or columns
that have paths--- " );
// END SNIPPET: execute
// START SNIPPET: items
Iterator<Node> n_column = result.columnAs( "n" );
for ( Node node : IteratorUtil.asIterable( n_column ) )
{
// note: we're grabbing the name property from the node,
// not from the n.name in this case.
nodeResult = node + ": " + node.getProperty( "name" );
}
// END SNIPPET: items
}
*Example Query:*
neo4j-sh (?)$ START a=node(448091),
b=node(6573222)
MATCH p=allshortestpaths((a)-[*..10]-(b))
return extract(n IN nodes(p)| n.title), extract(r IN rels(p)| r.weight);
*Example path results in colunms to be iterated over:*
+-----------------------------
------------------------------------------------------------------------------------------------------------+
| extract(n IN nodes(p)|
n.title)
| extract(r IN rels(p)| r.weight) |
+-----------------------------------------------------------------------------------------------------------------------------------------+
| ["Fieldale","Cannon Mills","Davidson College","Edinburgh Festival
Fringe","Yasser (play)"] | [<null>,<null>,0.5,<null>] |
| ["Fieldale","Cannon Mills","Davidson College","The Merchant of
Venice","Yasser (play)"] | [<null>,<null>,0.5,<null>] |
| ["Fieldale","Bassett High School","English","Haarlem","Yasser
(play)"] | [<null>,<null>,0.5,<null>] |
| ["Fieldale","Cannon Mills","New York City","Haarlem","Yasser
(play)"] | [<null>,<null>,0.5,<null>] |
| ["Fieldale","Fieldale, Virginia","Hispanic","Moroccan","Yasser
(play)"] | [<null>,0.5,0.5,<null>] |
| ["Fieldale","Fieldale, Virginia","Hispanic","Arab","Yasser
(play)"] |
[<null>,0.5,0.5,<null>] |
| ["Fieldale","Henry County, Virginia","Hispanic","Moroccan","Yasser
(play)"] | [0.5,0.5,0.5,<null>] |
--
You received this message because you are subscribed to the Google Groups
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.