That's probably because you'd want to use two different _m's_ otherwise the
first m is reused for the second match.

MATCH (n:TYPE)
WHERE n.id = 'hellyeah'
OPTIONAL MATCH (n)-[r:P]-(m1)
OPTIONAL MATCH (n)-[s:P2]-(m2)
RETURN n,r,s,m1,m2

You can also optimize this a bit to do the second bit of matches not for
each of the first
Something like this:

MATCH (n:TYPE)
WHERE n.id = 'hellyeah'
OPTIONAL MATCH (n)-[r:P]-(m1)
WITH n, collect({rel:r, node:m1}) as neighbours
OPTIONAL MATCH (n)-[s:P2]-(m2)
WITH collect({rel:s, node:m2}) + neighbours as neighbours
UNWIND neighbours  as nb
RETURN nb





On Fri, Aug 8, 2014 at 1:04 AM, gg4u <[email protected]> wrote:

> Hi folks!
>
> so, today I was experimenting on obtaining a linear combination out of
> multiple types of properties.
> Suppose you have multiple REL types, each with weighted properties.
>
> I am trying to obtain a collection? of first neighbors to a node, ordered
> by the sum of two weights.
>
> Here's what i've done:
>
> MATCH (n:TYPE)
> WHERE n.id = 'hellyeah'
> OPTIONAL MATCH n-[r:P]-m
> OPTIONAL MATCH n-[s:P2]-m
> RETURN n,r,s,m
>
> with this query, i get a table BUT all values of s are set as
> NULL
> could you help me understand
> why?
>
> thank you!
>
>  --
> 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.
>

-- 
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.

Reply via email to