我尝试使用过滤器来获取在gremlin中至少有一个邻居的所有顶点,但是出现错误,我是否误用了过滤功能?谢谢
g.V().hasLabel("Customer", "Loan", "Account", "CreditCard").filter(both().hasNext())
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