[英]How do I find disconnected nodes on neo4j with Cypher?
I am toying with neo4j and noticed that all Cypher queries need a starting point in the START
clause. 我正在玩neo4j并注意到所有Cypher查询都需要START
子句中的起点。 I was wondering how can I find all disconnected nodes using Cypher ? 我想知道如何使用Cypher找到所有断开连接的节点?
thanks 谢谢
If all your nodes are indexed (eg via auto-indexing) you could use an index query as a start point and then find those nodes that have no outgoing relationships. 如果所有节点都已编制索引(例如,通过自动索引),则可以使用索引查询作为起点,然后查找那些没有传出关系的节点。
start n=node:node_auto_index("id:*")
match n-[r?]->m
where r is null
return n
Nowadays I would rather use: 现在我宁愿使用:
start n=node:node_auto_index("id:*")
where not (n-->m)
return n
I use something like this, but only when I'm using spring-data-neo4j: 我使用这样的东西,但只有当我使用spring-data-neo4j:
start n = node:__types__(className="com.app.entity.Model")
// match, where...
return n
Hope that helps! 希望有所帮助!
With Neo4j v3.0+ I just use; 使用Neo4j v3.0 +我只是用;
MATCH (n)
WHERE NOT (n)--()
RETURN n
(or variations thereof). (或其变体)。 The query is reasonably fast. 查询速度相当快。
You can't. 你不能。 Graph global queries are not possible with todays Cypher. 今天的Cypher无法实现图形全局查询。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.