Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gremlin 将自己的帖子包含在跟踪用户的帖子中_Gremlin_Gremlinpython - Fatal编程技术网

Gremlin 将自己的帖子包含在跟踪用户的帖子中

Gremlin 将自己的帖子包含在跟踪用户的帖子中,gremlin,gremlinpython,Gremlin,Gremlinpython,我想从用户的跟帖中获取所有帖子以及我自己的帖子,以创建一个新闻提要 g.V().has('name', 'Bob').both('is_friend').out('has_posted').as('posts') 上面的代码只返回跟踪用户的帖子 如何包含我自己的帖子?您可以使用union和identity步骤: g.V().has('name', 'Bob').union( both('is_friend'), identity()) .out('has_posted'

我想从用户的跟帖中获取所有帖子以及我自己的帖子,以创建一个新闻提要

g.V().has('name', 'Bob').both('is_friend').out('has_posted').as('posts')
上面的代码只返回跟踪用户的帖子


如何包含我自己的帖子?

您可以使用
union
identity
步骤:

g.V().has('name', 'Bob').union(
    both('is_friend'),
    identity())
    .out('has_posted').as('posts')

您可以看到问题的“实时”示例(只需运行查询)

您可以使用
union
identity
步骤:

g.V().has('name', 'Bob').union(
    both('is_friend'),
    identity())
    .out('has_posted').as('posts')
您可以看到问题的“实时”示例(只需运行查询)