Hi,

I started looking at the results from this, and changing my code to deal
with Relationships returned from a query - and discovered that this
query didn't return a list of Relationships, it returned a list of Paths.

Not sure where the bug /really/ is, but I filed it against Nigel as a
py2neo issue.

https://github.com/nigelsmall/py2neo/issues/502

The best thing about this bug is that the query should work unmodified
on any database with at least one relationship in it. The results will
be different, but the types returned should not be.  I've quoted the bug
report below for your reading pleasure ;-).


The query below should work on any database with at least one
relationship in it. It should return one row with these fields:
1. nodes: list-of-Nodes
2. relationships: list-of-Relationships

|MATCH start MATCH p = shortestPath( (start)-[*]-(m) ) UNWIND nodes(p) as
n UNWIND rels(p) as r RETURN collect(distinct n) as nodes,
collect(distinct r) as relationships |

But when I look at what py2neo is giving me, it returns
1. nodes: list-of-Nodes
2. relationships: list-of-/*Paths*/

This is with Neo4j 3.0.0, and Py2neo 2.0.8. It possible it's not your
problem, but a Neo4j problem, or even a bug/deficiency in the REST API.
But from reading your code, it looked like you weren't expecting this
kind of result.

"neo4j::all":"3.0.0",
"py2neo": "2.0.8",



On 04/28/2016 03:32 PM, Alan Robertson wrote:
> The query isn't quite right. It has an error in it (variable n already
> used) and something about the order of operations causes it to return
> more than one row - with duplicates ;-)
>
> But this one seems to do the trick:
> |match path = shortestPath( (n)-[*]->(m) ) return collect(distinct
> unwind(nodes(path))), collect(distinct unwind(rels(path)))|
>
> What do you think?
>
>
>
> On 04/28/2016 07:59 AM, Alan Robertson wrote:
>> Hi,
>>
>> Michael Hunger separately provided me this query - which is a
>> prototype query which looks like it will do what I want. It includes
>> features of Cypher I was not familiar with (particularly unwind):
>>
>>> |.... match path = shortestPath( (n)-[*]->(m) ) unwind nodes(path) as
>>> n with collect(distinct n) as nodes unwind rels(path) as r return
>>> collect(distinct r), nodes|
>> If I understand it correctly, this returns a single tuple with two
>> elements:
>>
>>  1. List of all individual relationships (no duplicates)
>>  2. List of all individual nodes (no duplicates)
>>
>> I'll have to try this out!
>>
>> I kind of wonder how this gets mapped into py2neo - what type are the
>> tuple elements -- list(Relationship) and list(Node) or something like
>> that...
>>
>> *Nigel?*
>>
>> I know my code won't currently handle this - but I can fix that ;-)
>>
>>     -- Alan
>>
>
>
> -- 
>
> Alan Robertson / CTO
> al...@assimilationsystems.com <mailto:al...@assimilationsystems.com>/
> +1 303.947.7999
>
> Assimilation Systems Limited
> http://AssimilationSystems.com
>
> Twitter <https://twitter.com/ossalanr> Linkedin
> <https://www.linkedin.com/in/alanr> skype
> <https://htmlsig.com/skype?username=alanr_unix.sh>
>
> -- 
> 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 neo4j+unsubscr...@googlegroups.com
> <mailto:neo4j+unsubscr...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.


-- 

Alan Robertson / CTO
al...@assimilationsystems.com <mailto:al...@assimilationsystems.com>/ +1
303.947.7999

Assimilation Systems Limited
http://AssimilationSystems.com

Twitter <https://twitter.com/ossalanr> Linkedin
<https://www.linkedin.com/in/alanr> skype
<https://htmlsig.com/skype?username=alanr_unix.sh>

-- 
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 neo4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to