Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
10-08-2022 12:04 PM - edited 10-09-2022 02:52 AM
I'm trying to find relationship count over a pattern / path. Where I need result even if the whole pattern doesn't exist (pattern exist partially)
MATCH (u:USER {first_name:'xyxy'})
OPTIONAL MATCH (u)<-[t1]-(:METADATA)-[t2]->(:USER)
RETURN count(distinct t1)
Query returns t1 count only if both t1 and t2 relationships exist in pattern.
But if t1 exit and t2 doesn't, then the t1 in the return gives me 0.
Is there any way to get result even if pattern partially exist. Any thoughts / suggestions?
10-15-2022 07:15 AM - edited 10-15-2022 07:16 AM
Hello @venkat12 🙂
You could do something like this:
MATCH (u:USER {first_name:'xyxy'})
OPTIONAL MATCH (u)<-[t1]-(m:METADATA)
OPTIONAL MATCH (m)-[t2]->(:USER)
RETURN count(DISTINCT t1), count(DISTINCT t2)
Regards,
Cobra
All the sessions of the conference are now available online