我有跟随顶点和边缘。
User1 -> create ->Post1
Post1 -> postedOnWall -> User2
User2 -> create ->Comment1
Comment1 -> PostedOnComment -> Post1
User3 -> create -> Comment2
Comment2 -> PostedOnComment -> Post1
User1创建了Post1并将其发布在User2的Wall上。现在User2创建了一个评论并将其发布在Post1上。 User3也在同一篇文章上发表评论。
如何获取用户墙上所有帖子的列表以及每个帖子中的所有评论。
我通过以下查询获取帖子列表:
GV(512)。在(' 标签'' WallPost&#39)。。{排序} it.PostedTime .reverse()()。如(' postInfo')[0..10]。在(' 标签''注释&#39)。()作为('评价&#39)。选择{它} {它}
无法找到任何方法来获取每篇帖子的评论列表。
答案 0 :(得分:1)
使用select()
步骤让你非常接近,但我认为transform()
可能就是你想要的。我在gist发布了一个完整的Gremlin控制台会话结果,但关键部分是:
gremlin> g.V('name','user2').in('PostedOnWall').sort{ a, b -> b.PostedTime <=> a.PostedTime }._().transform{ [post: it.msg, comments: it.in('PostedOnComment').msg.toList()] }
==>{post=what is for dinner?, comments=[tacos]}
==>{post=hello, comments=[buenos dias, bongiorno]}