Gremlin 小精灵海王星-由不';不存在于所有顶点中

Gremlin 小精灵海王星-由不';不存在于所有顶点中,gremlin,amazon-neptune,Gremlin,Amazon Neptune,假设我有一个带有“person”顶点的图。 每个顶点都有“名称”和“年龄”属性,只有一个除外 现在我试着按年龄排序: g.V().order().by('age', asc).valueMap() 但它失败了: "The property does not exist as the key has no associated value for the provided element: v[328]:age" 看看这个: 我如何用0来“替换”丢失的属性?谢谢 您可以使用

假设我有一个带有“person”顶点的图。 每个顶点都有“名称”和“年龄”属性,只有一个除外

现在我试着按年龄排序:

g.V().order().by('age', asc).valueMap()
但它失败了:

"The property does not exist as the key has no associated value for the provided element: v[328]:age"
看看这个:


我如何用0来“替换”丢失的属性?谢谢

您可以使用
常量
来填写缺少的值:

g.V().
  order().
    by(coalesce(
        values('age'),
        constant(0)
      ), asc).
  valueMap()
例如:

或者提前过滤它们:

g.V().
  .has('age')
  order().
    by('age', asc).
  valueMap()
例如: