如何在 Neo4j Cypher 中的节点级别过滤数据 [英] How to filters data at node level in Neo4j Cypher

查看:72
本文介绍了如何在 Neo4j Cypher 中的节点级别过滤数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我们有两场比赛,现在我们想要这样的东西(match1-match2)

Let suppose we have two match and now we want something like that (match1-match2)

match (u:User)-[r:HAS_RESOURCES]-(resource:Resource) where id(u)=1484
 match (resource1:Resource)-[r1:OWNED_BY_USER]-(owner:User) where resource1.isPublished=true return resource1

我们制作的这个密码.所以现在我们想要这样的东西 id(resource1)-id(resource)

This cypher we made . So now we want something like this id(resource1)-id(resource)

推荐答案

您可以过滤不在集合中的资源.

you can filter resources that are not in a collection.

确保在 :Resource(isPublished) 上有一个索引,否则你必须扫描所有资源.

Make sure to have an index on :Resource(isPublished) otherwise you have to scan across all resources.

match (u:User)-[r:HAS_RESOURCES]-(resource:Resource) where id(u)=1484
with collect(resource) as resources
match (resource1:Resource) 
where resource1.isPublished=true and NOT (resource1 IN resources)
return resource1

这篇关于如何在 Neo4j Cypher 中的节点级别过滤数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆