Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
02-11-2019 07:20 AM
Hey, hopefully we're just missing something but can someone tell me if this isn't possible?
We're trying to match these two patterns here:
(:User)-[:BELONGS_TO]->(:Crew)-[:BELONGS_TO]->(:Company)
(:User)-[:BELONGS_TO]->(:Company)
Using this query:
MATCH (user:User)-[:BELONGS_TO*0..]->(:Crew)-[:BELONGS_TO]->(:Company)
RETURN DISTINCT user
But we get no results back. However, doing this query works when we don't specify the :Crew
label:
MATCH (user:User)-[:BELONGS_TO*0..]->()-[:BELONGS_TO]->(:Company)
RETURN DISTINCT user
Any ideas why you can't specify the label on the intermediate?
02-11-2019 07:53 AM
Unless there's a bug, this path may not exist. Can you find in your graph a path in which the pattern matches? You may want to double-check for typos or casing mismatches, as well as checking the directions of the relationships.
02-11-2019 12:33 PM
Thanks for responding!
If you look at the above picture, you can see 3 scenarios:
(:User)-[:BELONGS_TO*0..1]->(:Crew)-[:BELONGS_TO]->(:Company)
:Crew
label in the middle:(:User)-[:BELONGS_TO*0..1]->()-[:BELONGS_TO]->(:Company)
:Crew
label(:User)-[:BELONGS_TO*0..1]->(:Crew)-[:BELONGS_TO]->(:Company)
Think it could be a bug?
02-11-2019 12:51 PM
Doesn't look like a bug to me.
I would guess that the top image doesn't feature the same user as the others (please confirm the uid of the user in the top image (with 3 nodes).
The second image shows that these two nodes fit the pattern, with the :User with the provided uid not having any :Crew node it belongs to. It fits the pattern because it traverses 0 :BELONGS_TO relationships (so the empty node in the pattern is the same node as the :User node), then it traverses another :BELONGS_TO relationships to a :Company node.
The third image shows that there is no such pattern where the :User in question meets the pattern, since there is no :Crew node that is reachable via outgoing :BELONGS_TO relationships.
All the sessions of the conference are now available online