Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
04-30-2020 11:35 AM
Hi all!
New to neo4j and learning cypher... Still very fresh, and my use of nomenclature is going to be rough, but I'm hoping someone may be able to help me out with doing the following:
I'm trying to get all nodes that have edges to two nodes of the same label that contain two different properties.
Effectively, I'm trying to figure out if there's a way to perform an AND operation on the properties contained within the two nodes connected to the target node.
e.g. something like this, but obv this is not going to work
MATCH (c: Child)
WHERE (c: Child)-{:Has}-(Parent{name: "Bob"} and Parent{name:"Susan"})
RETURN c
I'm hoping there's a really easy inline way of doing this, because I realize that what I'm trying to do with AND requires evaluating a set of at least 2 Parent entities, and the above syntax is only looking at one Parent at a time.
I've tried using the collect() method to aggregate all results containing bob, and susan, but I don't know how to use the syntax to get an intersection between the two.
Any help would be greatly appreciated, thanks!
04-30-2020 01:00 PM
MATCH (:Parent{name: 'Bob'})-[:Has]->(c:Child)<-[:Has]-(:Parent{name:'Susan'})
RETURN c
07-05-2021 09:50 PM
neat trick!
since you're using route-to ->
and <- route-from
does this generalize if there were more than two parent nodes?
how would you find if he wanted to find any
from a list of N options?
All the sessions of the conference are now available online