我想要像Cypher一样,
OPTIONAL MATCH (a1:Article) WHERE a1.status='active'
WITH collect(a1) as a1_col
OPTIONAL MATCH (a2:Article) WHERE a2.category='xyz'
WITH DISTINCT a1_col + collect(a2) as a
MATCH (a)-[:author]->(u:User)
WHERE NOT id(u)=101
RETURN a
我在这个密码中遇到Type mismatch: a already defined with conflicting type List<Node>
错误,对此的任何帮助都将非常感激。我需要OPTIONAL_MATCH和MATCH子句在这里分开。
答案 0 :(得分:1)
变量a
是List<Node>
,您可以在MATCH
子句中将其用作Node
。
您应该使用此查询:
OPTIONAL MATCH (a1:Article) WHERE a1.status='active'
WITH collect(a1) as a1_col
OPTIONAL MATCH (a2:Article) WHERE a2.category='xyz'
WITH DISTINCT a1_col + collect(a2) as a
MATCH (article)-[:author]->(u:User)
WHERE NOT id(u)=101 AND article IN a
RETURN a
我认为您可以像这样优化查询:
MATCH (u:User) WHERE id(u)=101 WITH u
MATCH (a:Article)
WHERE (a.category='xyz' OR a.status='active') AND
NOT (a)-[:author]->(u)
RETURN collect(DISTINCT a)