【问题标题】:Gremlin query with where has syntax error带有 where 的 Gremlin 查询有语法错误
【发布时间】:2023-01-09 06:07:50
【问题描述】:

我正在使用 gremlin 控制台,我有以下查询: g.V().hasLabel("Account").where(in("Account").hasLabel("Opportunity").count().is(2))

groovysh_parse: 1: unexpected token: in @ line 1, column 33.
   g.V().hasLabel("Account").where(in("Account").hasLabel("Opportunity").count().is(2))
                                   ^

1 error

它应该查询所有标记为“帐户”的顶点,其中有 2 个以上的边来自标记为“机会”的顶点但是我在 gremlin 控制台中收到以下错误,我不知道为什么,因为即使 chatGPT 说语法没问题

【问题讨论】:

    标签: gremlin graph-databases


    【解决方案1】:

    在 Groovy 中(Gremlin 控制台基于 Groovy 控制台)in 是一个保留字。尝试改用这个:

    g.V().hasLabel("Account").
      where(__.in("Account").hasLabel("Opportunity").count().is(2))
    

    __(双下划线)类可用于解决此类保留字冲突。这称为“匿名遍历源”。

    【讨论】:

      猜你喜欢
      • 2014-05-20
      • 1970-01-01
      • 2014-08-17
      • 2017-12-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多