Reputation: 767
I am trying to retrieve related data from multiple related nodes with the following cypher:
Match (n {email:{paramEmail}})-[*..3]-(m) Return n,m",
{ paramEmail: email})
The problem is if there are no existing relationship as yet then I get zero rows returned...user not found though the user(n) exist but at this point have no relationships. I still need the properties from the user(n) node so I have to make a separate call. Is there a query that would return n even though there was no relationship with m?
Upvotes: 0
Views: 198
Reputation: 30397
Yes, match on the user with the email first, and then use an OPTIONAL MATCH for the rest:
MATCH (n {email:{paramEmail}})
OPTIONAL MATCH (n)-[*..3]-(m) Return n,m
Also, I'd advise you to use labels on your nodes. That way you could look up a :User by their email quickly (after creating an index on :User(email)). Right now the query has to scan all nodes of your graph to find those with the given email parameter.
Upvotes: 1