OrientDB:如何将嵌套层次结构展平为单个记录

OrientDB: How to flatten nested heirarchy into a single record

我的结构看起来像这样:

我如何遍历我的页面并返回一个平面记录,以便每一行代表来自根节点及其边缘的所有数据。我的用例是我正在生成一个 csv 文件。

所以在上面的示例中,我想为每个 post 创建一行。每条记录应包含 post、语言名称、页面名称和网络名称中的所有字段。

据我所知,当你进行任何类型的遍历时,它只会给你最终顶点的结果,而不是中间顶点的任何数据。

试试这个查询:

select *,out('posted_to').name as page,out('posted_to').out('is_language').name as language,out('posted_to').out('is_network').name as network from <class Post> unwind page,language,network 

如果每页有很多帖子,则将查询锚定在页面上可能比从帖子开始更有效。

因此:

select focus.in() as post,
       focus.name as page,
       focus.out("is_language").name as language,
       focus.out("is_network").name as network
from (select @this as focus from Page)
unwind post, language, network, page

----+------+-----+----+--------+-------
#   |@CLASS|post |page|language|network
----+------+-----+----+--------+-------
0   |null  |#11:0|1   |Welsh   |1      
1   |null  |#11:1|1   |Welsh   |1      
2   |null  |#11:2|1   |Welsh   |1      
3   |null  |#11:3|1   |Welsh   |1      
4   |null  |#11:4|1   |Welsh   |1      
5   |null  |#11:5|1   |Welsh   |1      
6   |null  |#11:6|1   |Welsh   |1      
----+------+-----+----+--------+-------