英文:
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".
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论