生成 Neo4j 查询结果的分类法或文本表示

Generating taxonomy or text representation of Neo4j Query Result

我将基于 CSV 的分类法加载到 Neo4j 中,其中每个节点代表 Neo4j 中的层次结构位置。换句话说,每个节点都具有 parent_of 和 child_of 关系,具体取决于它是层次结构的子集还是超集。

示例分类法:

Ambiguous, Moon
Aerospace and electronic systems
Aerospace and electronic systems, Moon
Aerospace and electronic systems, Aerospace engineering, Satellites, Moon, Man on the Moon

示例节点:

Moon
Ambiguous

其中 "Moon" 是 child_of "Ambiguous" 而 "Ambiguous" 是 parent_of "Moon" 等

现在我想在数据库中搜索特定节点并根据搜索结果重新创建其分类层次结构。

所以首先我 运行 密码查询:

MATCH (n)-[:PARENT_TO*]->(m) where m.term = "Man on the Moon" RETURN n,m;

并得到以下信息:

我的Question/Problem是:

table 版本仅提供 "n" 和 "m" 映射。我无法推断出术语之间的任何深度级别 - 因此我无法重新创建层次结构。

那么,如何使用搜索和查询结果重新生成多级层次结构?

您可以return节点之间的整个路径:

MATCH path = (n)-[:PARENT_TO*]->(m) where m.term = "Man on the Moon" 
RETURN nodes( path )