2

I Have problem that solved by checking two different type of relation for two same node.

For example, we have to Match section as below:

1. Match("(u:User)-[r:USER_IN_SITE]->(w:WebEnvir)")
    .Return(u => u.As<TUser>())
                        .Results;
  2. Match("(u:User)-[r2:USER_IN_CLOUD]->(w:WebEnvir)")
    .Return(u => u.As<TUser>())
                        .Results;

How Can I make merge or union between Match ?

Mayur Prajapati
  • 5,454
  • 7
  • 41
  • 70

1 Answers1

1

You can do a UNION (which I'm not sure how to do it neo4jclient), but you can also do this, I think (in pure Cypher):

MATCH (u:User), (w:WebEnvir)
OPTIONAL MATCH
  (u)-[r:USER_IN_SITE]->(w), (u)-[r2:USER_IN_CLOUD]->(w)
RETURN u, w, collect(r), collect(r2)

Beware, though, because you'll be getting a full cartesian product either way (actually you'd be doing it twice with a UNION, I think). Depending on how many User and WebEnvir nodes you have, that could be a really big query

Brian Underwood
  • 10,746
  • 1
  • 22
  • 34