【问题标题】:Gremlin : Checking existence in traversal step or setGremlin:检查遍历步骤或集合中的存在
【发布时间】:2022-01-19 03:15:48
【问题描述】:

背景:

我正在尝试通过图表运行搜索,并根据发现的节点是否属于执行查询之前可用的预定义集来更改搜索行为。

我找不到任何关于如何交叉检查 gremlin 中的集合中是否存在顶点或属性的文档。

示例:

给定:g.V('id1', 'id2', 'id3').as('a')

查找:如果a 包含'id4'

给定:g.V('id1', 'id2', 'id3').fold().store('a') => ['id1', 'id2', 'id3']

查找:如果a 包含id4

【问题讨论】:

    标签: gremlin tinkerpop


    【解决方案1】:

    解决此问题的一种方法是使用coalesce 步骤。这是 Gremlin 控制台中的一个简单示例。

    gremlin> g.V(1,2,3).fold().as('found').V(3).coalesce(where(within('found')).constant('found'),constant('not found'))
    ==>found
    
    gremlin> g.V(1,2,3).fold().as('found').V(4).coalesce(where(within('found')).constant('found'),constant('not found'))
    ==>not found 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-24
      • 2020-03-23
      • 2021-11-27
      • 2021-12-21
      • 2021-12-13
      相关资源
      最近更新 更多