如何获取gremlin中至少有一个邻居的所有顶点?

问题描述 投票:0回答:1

我尝试使用过滤器来获取在gremlin中至少有一个邻居的所有顶点,但是出现错误,我是否误用了过滤功能?谢谢

g.V().hasLabel("Customer", "Loan", "Account", "CreditCard").filter(both().hasNext())
gremlin tinkerpop janusgraph
1个回答
0
投票

hasNext()
是最后一步。 它仅适用于查询末尾,而不是查询内:https://tinkerpop.apache.org/docs/current/reference/#terminal-steps

您可以通过执行以下操作来实现您正在寻找的目标:

g.V().hasLabel("Customer", "Loan", "Account","CreditCard").
    where(bothE().count().is(gt(0)))

如果使用 Gremlin 客户端之一发出此命令,您需要使用

next()
toList()
或其他一些终端步骤来结束此操作,以将查询发送到数据库并获取结果。

如果您正在寻找学习 Gremlin 的好资源,我强烈建议您查看:https://www.kelvinlawrence.net/book/PracticalGremlin.html

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.