Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
12-29-2022 11:43 AM
My simple 4 node graph is:
(thing:Steve) -[is]-> (thing:Person) -[does]-> (action:living) <-[is]- (action:breathing)
but this query
MATCH (a:thing),(b:action)
OPTIONAL MATCH (a)-[r]-(b)
OPTIONAL MATCH (a)-[r1]-(a)
OPTIONAL MATCH (b)-[r2]-(b)
return *
returns
│"a" │"b" │"r" │"r1"│"r2"│
│{"name":"Steve"} │{"name":"living"} │null│null│null│
│{"name":"Steve"} │{"name":"breathing"}│null│null│null│
│{"name":"person"}│{"name":"living"} │{} │null│null│
│{"name":"person"}│{"name":"breathing"}│null│null│null│
Why doesn't the query return R1 (steve is person) nor R2 (breathing is living)?
(It only returns a->b... person is living)
12-29-2022 01:34 PM
This syntax is a little confusing in terms of what each node’s label is.
(thing:Steve) -[is]-> (thing:Person) -[does]-> (action:living) <-[is]- (action:breathing)
anyways, it looks like your ‘thing’ node (“steve”) is more than one hop away from either ‘action’ node (“living” and “breathing”). You pattern matches are all one hop patterns, thus no matches returning relationships.
All the sessions of the conference are now available online