简体   繁体   English

如何使用Cypher在neo4j上找到断开连接的节点?

[英]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.

相关问题 Neo4j(密码):如何找到具有特定关系的所有节点? - Neo4j (cypher): How do I find all nodes with a specific relationship? 如何在cypher / neo4j中找到与一系列节点相关联的最亲密的人 - How do I find the most connected person associated with a series of nodes in cypher/neo4j 我如何找到 neo4j cypher? - How i find neo4j cypher? 使用neo4j的Cypher,我如何找到最大组直径为3的断开连接的节点组 - With neo4j's Cypher how can I find disconnected node groups with a maximum group diameter of 3 如何在 Cypher Neo4j 中获取不包含(相关)具有特定属性的节点的所有节点 - How do I get all nodes that do not contain (relate) nodes with certain property in Cypher Neo4j 如何找到Neo4j和Cypher中的一系列连接节点的头部? - How to find the head of a series of connected nodes in Neo4j with Cypher? 如何在Neo4j / Cypher查询中查找不同的节点 - How to find distinct nodes in a Neo4j/Cypher query 如何使用cypher从neo4j中的不同文件加载节点和边? - How do I load nodes and edges from different files in neo4j using cypher efficiently? 如何在使用 APOC 的 Neo4j 中的虚拟节点和关系上运行 cypher 查询? - How do I run a cypher query on virtual nodes and relationships in Neo4j ceated using APOC? 如何在Neo4j Cypher中提供多个查询? - How do I provide multiple queries in Neo4j Cypher?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM