我正在尝试使用neo4j,并注意到所有Cypher查询都需要在START子句中设置起始点。我想知道如何使用Cypher查找所有未连接的节点?谢谢。
start n=node:node_auto_index("id:*")
match n-[r?]->m
where r is null
return n
现今我更倾向于使用:
start n=node:node_auto_index("id:*")
where not (n-->m)
return n
MATCH (n)
WHERE NOT (n)--()
RETURN n
(或其变种)。查询速度相当快。
我通常只在使用spring-data-neo4j时才会使用类似这样的东西:
start n = node:__types__(className="com.app.entity.Model")
// match, where...
return n
不行。目前的Cypher无法进行全局图查询。
START a=node(*) WHERE NOT ((a)--()) RETURN a;
- firefly2442