如何在 Gremlin 中检索多个多属性?

How do I retrieve multiple multi-properties in Gremlin?

我有一个 Person 对象,我正在将其写入这样的图形:

gts.addV(newId).label('Person')
  .property(single, 'name', 'Alice')
  .property(set, 'email', 'alice1@example.invalid')
  .property(set, 'email', 'alice2@example.invalid')

现在我想检索顶点的内容。如文档所述,elementMap 不起作用,因为它 returns 只是多属性的单个 属性 值。我尝试了 values('name', 'email'),但它返回了扁平化列表中的所有属性,而不是我预期的嵌套结构:

['Alice', 'alice2@example.invalid', 'alice1@example.invalid']

我已经尝试了 valuesprojectas/select 的各种组合,但我总是得到空结果、平面列表或多值上的单个值属性。

我如何查询顶点才能得到类似这些结果?

['Alice', ['alice2@example.invalid', 'alice1@example.invalid']]

[name:'Alice', email:['alice2@example.invalid', 'alice1@example.invalid']]

如果您只是在寻找 return 值的映射,您可以使用 valueMap() step:

g.V(newId).valueMap('name', 'email')

这将 return:

[name:[Alice],email:[alice1@example.invalid,alice2@example.invalid]]

如果您只想 return 值,您可以通过添加 select(values):

g.V().valueMap('name', 'email').select(values)

哪个return

[[Alice],[alice1@example.invalid,alice2@example.invalid]]