How to filters data at node level in Neo4j Cypher

怎甘沉沦 提交于 2020-01-17 08:16:06

问题


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

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


回答1:


you can filter resources that are not in a collection.

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


来源:https://stackoverflow.com/questions/28477459/how-to-filters-data-at-node-level-in-neo4j-cypher

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!