仅显示关系中具有特定属性的节点

时间:2019-06-21 14:05:05

标签: neo4j cypher

我是neo4j的新手,正在为构建简单的过滤器而苦苦挣扎。

我玩了一下,发现了in运算符,但它只列出找到至少一场比赛的每个“人”。我只想列出包含所有属性的“人”。

MATCH (p:Person)-[l:LIKES]->(f:Food) WHERE f.name in ["Spaghetti","Cheese","Chicken","Eggs"]
RETURN p

结果:仅显示“意大利面”,“奶酪”,“鸡肉”,“鸡蛋”,...之类的“人” ...

1 个答案:

答案 0 :(得分:1)

我们在performing match intersection上有一篇知识库文章应该对此进行解决。

根据您的情况,这是您可以使用的一种方法:

WITH ["Spaghetti","Cheese","Chicken","Eggs"] as foods
MATCH (p:Person)-[:LIKES]->(f:Food) 
WHERE f.name in foods
WITH p, foods, count(f) as foodsLiked
WHERE foodsLiked = size(foods)
RETURN p