Ok a couple more hours of tinkering and I worked it out. Here is what i did
in case any one else wants to follow this path of returning graphs back
rather than rows:
MATCH (a:A{email:"[email protected]"})-[rels:r1|r2|r3|r4|r5|r6|r7]-()
RETURN user, rels
This effectively returns you all "optional relationships" that you are
interested in. Returns in under around 100ms.
For what it's worth you can then structure more complexity over the top.
For me i was interested in bringing down more nodes if a relationship
condition was met.
MATCH (a:A{email:"[email protected]"})-[rels:r1|r2|r3|r4|r5]-(n)
WITH a, rels, n
OPTIONAL MATCH (n:B)-[bRel:r8]-()
OPTIONAL MATCH (n:C)-[cRel:r9]-()
RETURN a, rels, bRel, cRel
::mark
On Tuesday, October 28, 2014 9:47:33 AM UTC+11, Mark Angrish wrote:
>
> Hi there,
>
> I have been trying to solve this bizarre problem for a day now and I can't
> figure it out. I have the following cypher:
>
>
> MATCH (a:A{email:"[email protected]"})
> OPTIONAL MATCH (a)-[r1:r1]-()
> OPTIONAL MATCH (a)-[r2:r2]-()
> OPTIONAL MATCH (a)-[r3:r3]-()
> OPTIONAL MATCH (a)-[r4:r4]-()
> OPTIONAL MATCH (a)-[r5:r5]-()
> OPTIONAL MATCH (a)-[r6:r6]-()
> OPTIONAL MATCH (a)-[problem:r7]-()
> RETURN a, r1, r2, r3, r4, r5, r6, r7
>
>
> There is a unique constraint on A:email. All the other nodes have unique
> constraints too (usually on a uuid).
>
> So I am using the REST API and passing in:
>
> "resultDataContents":["graph"]
>
> This is to minimise the data sent over the wire and because I map the
> results to my domain objects. row based/jdbc sends way too much data and
> can't return properties on relationships AFAIK.
>
> The problem i'm having is that by including the relationship problem:r7 my
> cypher query goes from around 1sec (without it) to around 40 sec (with it).
> The total data it needs to return is about 100-150 nodes.
>
> I have ordered the relationships in order of reducing cardinality to make
> searching easier. If i do a count distinct return query for
> a:A-[problem:r7]-() the query returns in about 120ms.
>
> Does anyone have any ideas? Also it might matter but it might not: I have
> upgraded the db several times from 2.1.3 -> 2.1.4 -> 2.1.5.
>
>
>
>
--
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.