Gremlin查询中的”where has”语法错误。

huangapple go评论65阅读模式
英文:

Gremlin query with where has syntax error

问题

我正在使用Gremlin控制台,并且我有以下查询:

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

但是我在Gremlin控制台中收到以下错误,我不知道为什么,因为即使ChatGPT也说语法是正确的。

英文:

I am using the gremlin console and I have the following Query:
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

it should query all the vertices that are labeled as "Account" where which have more than 2 edges coming from vertices labeled as "Opportunity" however I get the following error in the gremlin console and I don't know why since even chatGPT says the syntax is ok

答案1

得分: 1

在Groovy中(Gremlin控制台基于Groovy控制台),in是一个保留字。请尝试改用以下方式:

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

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

英文:

In Groovy (the Gremlin Console is based on the Groovy Console) in is a reserved word. Try using this instead:

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

The __ (double underscore) class can be used to work around such reserved word conflicts. This is called an "anonymous traversal source".

huangapple
  • 本文由 发表于 2023年1月9日 00:09:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/75049323.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定