I am a newbie to the gremlin. I am trying to get some random vertices based on some condition. But if I am using sample method with some mathematical computation it is not working. But if I give integer values it is working fine.
The following query is working fine:
g.V().hasLabel('Person').sample(1)
The following query is not working:
g.V().hasLabel('Person').sample(math('4/2'))
Actually, based on the number of persons I should perform some mathematical computations inside sample method. Thanks in advance
That's an interesting bit of Gremlin you are trying to run. I've not seen anyone try that before. Sadly, it won't work because sample()
does not take a Traversal
as an argument. It only takes a number. There is no workaround for this issue aside from doing the computation outside of Gremlin which isn't helpful if you need to choose your sample size based on data in your query. sample()
isn't the only step that behaves this way. I've created TINKERPOP-2414 to track this issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With