简体   繁体   English

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

[英]Only show nodes that have a specific properties in relationship

I'm new to neo4j and im struggling with the task to build a simple filter. 我是neo4j的新手,并不喜欢构建简单过滤器的任务。

I played around and found the in operator but it only list me every "Person" where atleast one match is found. 我玩了一下,发现了in运算符,但它只列出找到至少一场比赛的每个“人”。 I want to only list "Person" that have all the properties included. 我只想列出包含所有属性的“人”。

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

Result: Show only "Person" that like "Spaghetti","Cheese","Chicken","Eggs", ... 结果:仅显示像“意大利面”,“奶酪”,“鸡肉”,“鸡蛋”,“ ...”之类的“人”。

We have a knowledge base article on performing match intersection that should address this. 我们有一个有关执行比赛相交的知识库文章,应该解决这个问题。

Applied to your case, here's one of the approaches you can use: 应用于您的案例,这是您可以使用的一种方法:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM