Gremlin:inject()和has()未按预期协同工作

Gremlin:inject()和has()未按预期协同工作,gremlin,tinkerpop,tinkerpop3,gremlin-server,azure-cosmosdb-gremlinapi,Gremlin,Tinkerpop,Tinkerpop3,Gremlin Server,Azure Cosmosdb Gremlinapi,我需要根据传递给inject()的列表创建不重复的顶点,该列表非常大,因此我需要使用inject()。我试过了,但没用: g.inject(["Macka", "Pedro", "Albert"]).unfold().map( coalesce( V().has("name", identity()), addV("user").property("

我需要根据传递给inject()的列表创建不重复的顶点,该列表非常大,因此我需要使用inject()。我试过了,但没用:

g.inject(["Macka", "Pedro", "Albert"]).unfold().map(
    coalesce(
        V().has("name", identity()),
        addV("user").property("name", identity())
    )
)
您可以在这里尝试:

为什么这不起作用?
似乎V().has()正在返回所有顶点,为什么?

我认为在这种情况下,应该使用
where
步骤,而不是
has

g.inject(["Macka", "Pedro", "Albert"]).unfold().as('n').map(
    coalesce(
        V().where(eq('n')).by('name').by(),
        addV("user").property("name", identity())
    )
)

示例:

has(字符串,遍历)
并不像大多数人认为的那样。此版本的
has()
旨在使用当前属性值作为遍历器,将匿名
遍历作为筛选器进行计算。它不会将
遍历
解析为将其用作
has()
对象的值。这里有一些讨论:这是一个好的选择吗
V().has(“name”,其中(eq(“n”))
我觉得它可读性更强,而且似乎可以正常工作