【问题标题】:Gremlin: How can I omit empty elements from the outputGremlin:如何从输出中省略空元素
【发布时间】:2020-07-18 06:59:52
【问题描述】:

我有一个返回这个的 gremlin 查询:

[Michael,Cleant,Jhonen]
[Michael,Cleant,Jhonen]
[]

我可以在查询中添加什么以从输出中删除空数组元素?

要创建此输出,您可以在 gremlin 控制台中使用此代码:

g.addV("user").property("name", "Michael")
g.addV("user").property("name", "Cleant")
g.addV("user").property("name", "Jhonen")

g.V().values("name").fold().store("a").V().values("name").fold().store("a").select("a").V().hasLabel("nonExistent").fold().store("a").select("a").unfold()

【问题讨论】:

    标签: gremlin tinkerpop tinkerpop3 gremlin-server


    【解决方案1】:

    您可以通过将以下内容附加到遍历的末尾来计算每个结果:

    where(count(local).is(gt(0)))
    

    或者可能更好,因为它会明确避免对所有列表进行完整计数:

    where(unfold())    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-02-20
      • 1970-01-01
      • 2010-12-18
      • 1970-01-01
      • 2013-03-13
      • 2016-05-05
      • 2019-07-20
      • 2015-06-26
      相关资源
      最近更新 更多