Reputation: 3033
In cypher id like to return all paths containing only a known set of valid relationship names using something like
MATCH (i:VALID_RELATIONSHIPS), p=(n:MY_DOMAIN)-[rels*1..5]-(m)
WHERE n.NAME='start_node' AND
ALL(t in rels WHERE type(t) IN extract(x IN i | x.RELATIONSHIP_NAME) )
RETURN nodes(p);
so ALL t IN rels
should be contained in the collection of VALID_RELATIONSHIPS
however this returns an exception i already defined with conflicting node type collection<any>
Am I misunderstanding something here? The algorithm should loop through all rels
(which I assume is a collection) in the path, and for each one; check that the type() is contained in the valid relationships collection i
Upvotes: 0
Views: 1378
Reputation: 41676
This one is of type Node: i
Why don't you pass in the valid relationship names as a parameter?
MATCH p=(n:MY_DOMAIN)-[rels*1..5]-(m)
WHERE n.NAME='start_node' AND
ALL(t in rels WHERE type(t) IN {valid_rel_names} )
RETURN nodes(p);
Otherwise you have to aggregate your i's into a collection first
MATCH (i:VALID_RELATIONSHIPS)
WITH collect(i) as valid_rels
MATCH p=(n:MY_DOMAIN)-[rels*1..5]-(m)
WHERE n.NAME='start_node' AND
ALL(t in rels WHERE type(t) IN extract(x IN valid_rels | x.RELATIONSHIP_NAME) )
RETURN nodes(p);
or already extract the rels upfront
MATCH (i:VALID_RELATIONSHIPS)
WITH collect(i.RELATIONSHIP_NAME) as valid_rel_names
MATCH p=(n:MY_DOMAIN)-[rels*1..5]-(m)
WHERE n.NAME='start_node' AND
ALL(t in rels WHERE type(t) IN valid_rel_names )
RETURN nodes(p);
Upvotes: 2