I'm sure this is straightforward, but I'm not sure how to do it. I have vertices, with a certain label, which have two integer properties. Let's call them integer1 and integer2. I simply want to query for all vertices where integer2 is greater than integer1.
I have tried the following:
g.V().hasLabel("myLabel").has("integer2", P.gt(values("integer1"))).toList();
but this results in an exception - understandably, as the the "values" method call results in a traversal step where as the predicate expects a number.
Exception in thread "main" java.lang.ClassCastException: org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal cannot be cast to java.lang.Integer
at java.lang.Integer.compareTo(Integer.java:52)
at org.apache.tinkerpop.gremlin.process.traversal.Compare$3.test(Compare.java:92)
at org.apache.tinkerpop.gremlin.process.traversal.P.test(P.java:72)
at org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer.testValue(HasContainer.java:118)
at org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer.test(HasContainer.java:94)
at org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer.testAll(HasContainer.java:180)
at org.apache.tinkerpop.gremlin.tinkergraph.process.traversal.step.sideEffect.TinkerGraphStep.iteratorList(TinkerGraphStep.java:116)
at org.apache.tinkerpop.gremlin.tinkergraph.process.traversal.step.sideEffect.TinkerGraphStep.vertices(TinkerGraphStep.java:88)
at org.apache.tinkerpop.gremlin.tinkergraph.process.traversal.step.sideEffect.TinkerGraphStep.lambda$new$0(TinkerGraphStep.java:59)
at org.apache.tinkerpop.gremlin.tinkergraph.process.traversal.step.sideEffect.TinkerGraphStep$$Lambda$23/1123629720.get(Unknown Source)
...
Any help would be greatly appreciated. Thanks.