admin管理员组文章数量:1025270
I tried to use filter to get all vertices which has at least one neighbour in gremlin, but get error, did I mis-use filter function? Thanks
g.V().hasLabel("Customer", "Loan", "Account", "CreditCard").filter(both().hasNext())
I tried to use filter to get all vertices which has at least one neighbour in gremlin, but get error, did I mis-use filter function? Thanks
g.V().hasLabel("Customer", "Loan", "Account", "CreditCard").filter(both().hasNext())
Share
Improve this question
asked Nov 18, 2024 at 14:01
zjffduzjffdu
29.2k51 gold badges121 silver badges171 bronze badges
1 Answer
Reset to default 0hasNext()
is a terminal step. It is only meant to be used at the end of a query, not within the query: https://tinkerpop.apache./docs/current/reference/#terminal-steps
You can achieve what you're looking for by doing something like:
g.V().hasLabel("Customer", "Loan", "Account","CreditCard").
where(bothE().count().is(gt(0)))
If issuing this using one of the Gremlin clients, you'll need to end this with next()
, toList()
or some other Terminal step to send the query to your database and fetch a result.
If you're looking for a good resource to use in learning Gremlin, I highly suggest looking at: https://www.kelvinlawrence/book/PracticalGremlin.html
I tried to use filter to get all vertices which has at least one neighbour in gremlin, but get error, did I mis-use filter function? Thanks
g.V().hasLabel("Customer", "Loan", "Account", "CreditCard").filter(both().hasNext())
I tried to use filter to get all vertices which has at least one neighbour in gremlin, but get error, did I mis-use filter function? Thanks
g.V().hasLabel("Customer", "Loan", "Account", "CreditCard").filter(both().hasNext())
Share
Improve this question
asked Nov 18, 2024 at 14:01
zjffduzjffdu
29.2k51 gold badges121 silver badges171 bronze badges
1 Answer
Reset to default 0hasNext()
is a terminal step. It is only meant to be used at the end of a query, not within the query: https://tinkerpop.apache./docs/current/reference/#terminal-steps
You can achieve what you're looking for by doing something like:
g.V().hasLabel("Customer", "Loan", "Account","CreditCard").
where(bothE().count().is(gt(0)))
If issuing this using one of the Gremlin clients, you'll need to end this with next()
, toList()
or some other Terminal step to send the query to your database and fetch a result.
If you're looking for a good resource to use in learning Gremlin, I highly suggest looking at: https://www.kelvinlawrence/book/PracticalGremlin.html
本文标签: tinkerpopHow to get all vertices which has at least one neighbour in gremlinStack Overflow
版权声明:本文标题:tinkerpop - How to get all vertices which has at least one neighbour in gremlin? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745612285a2159074.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论