在cypher id中,要使用类似
之类的内容返回仅包含一组已知有效关系名称的所有路径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);
所以ALL t IN rels
应该包含在VALID_RELATIONSHIPS
然而,这会返回异常i already defined with conflicting node type collection<any>
我在这里误解了什么吗?算法应循环遍历路径中的所有rels
(我假设是一个集合),并为每个;检查type()是否包含在有效的关系集合i
答案 0 :(得分:2)
这个类型为Node:i
为什么不将有效的关系名称作为参数传递?
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);
否则你必须先将你的i聚合成一个集合
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);
或已经提前提取了rels
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);