Neo4j | Cypher - 给定节点 A,显示到 C 类型节点 B 的路径,该节点 B 有超过 X 个 D 类型的子节点
Neo4j | Cypher - given node A, show me path to node B of C type which has more than X children of D type
查询的第一部分是查找 C 类型的节点,这些节点有 X 个 D[ 的子节点 类型,我有这个工作:
MATCH (Parent:$C)
WITH Parent, [(Child:$D)-[]-(Parent) | Child] as children
WITH Parent, children, size(children) as ChildCount
WHERE ChildCount > $X
RETURN Parent
现在我想获取节点 A 并找到从第一个查询返回的一些节点的路径。
我的查询如下所示:
//Part A - this one is already working
MATCH (Parent:FullAddress)
WITH Parent, [(Child:Company)-[]-(Parent) | Child] as children
WITH Parent, children, size(children) as ChildCount
WHERE ChildCount > 10
WITH Parent as Target
//Part B - this part doesn't work
MATCH Path = (S:Ship)-[*2]-(Target)
WHERE ID(S)=164758
RETURN nodes(Path)
LIMIT 100
预期的结果是向我显示 Ship
和 ID=164758
之间的路径和来自 查询 A 的节点之一。我确定这条路径存在,因为我在选择查询参数之前手动检查了它。
当前结果是 neo4j 加载到无穷大。
我猜查询对于 neo4j 来说太大了,因为我有 5,000,000 多个节点。
查询的第一部分是查找 C 类型的节点,这些节点有 X 个 D[ 的子节点 类型,我有这个工作:
MATCH (Parent:$C)
WITH Parent, [(Child:$D)-[]-(Parent) | Child] as children
WITH Parent, children, size(children) as ChildCount
WHERE ChildCount > $X
RETURN Parent
现在我想获取节点 A 并找到从第一个查询返回的一些节点的路径。 我的查询如下所示:
//Part A - this one is already working
MATCH (Parent:FullAddress)
WITH Parent, [(Child:Company)-[]-(Parent) | Child] as children
WITH Parent, children, size(children) as ChildCount
WHERE ChildCount > 10
WITH Parent as Target
//Part B - this part doesn't work
MATCH Path = (S:Ship)-[*2]-(Target)
WHERE ID(S)=164758
RETURN nodes(Path)
LIMIT 100
预期的结果是向我显示 Ship
和 ID=164758
之间的路径和来自 查询 A 的节点之一。我确定这条路径存在,因为我在选择查询参数之前手动检查了它。
当前结果是 neo4j 加载到无穷大。
我猜查询对于 neo4j 来说太大了,因为我有 5,000,000 多个节点。