Gremlin comparison between one node's own properties

I'm trying to have a query that will compare one node's properties without necessarily having to assign an alias to the node and was wondering whether this is possible in gremlin? As an example, I'd like to something like: g.V().hasLabel("person").where(__.values("age"), lt(__.values("dayofBirth"))) or g.V().hasLabel("person").where(__.values("name"), neq(__.values("birthdayMonth"))) , but this doesn't seem to work in gremlin. I know that something like this works instead: g.V().hasLabel("person").as("v").where(lt("v")).by("age").by("dayofBirth") , but it assigns an alias to the node before comparison. Is it necessary to assign an alias to a node in order to compare its own properties in gremlin? As an extension to this question, my goal would be to have a way to compare one node's properties in gremlin without having to assign an alias on that node, and also be able to do a comparison on different nodes with only one alias assigned to the node that is not directly adjacent to this query (something like this): g.V().hasLabel("person").as("a") .outE("isFriendsWith").inV() .hasLabel("dog") .filter(__.values("age").where(neq(__.select("a").values("age")))) but this doesn't seem to work in gremlin either. Do both aliases always have to be assigned to do a comparison on two different nodes and their properties?
4 Replies
Andrea
Andrea17h ago
Looking through code examples and documentation I can't seem to find examples of same node property comparison without the usage of alias. Just curious why usage of alias is looking to be avoided in your scenario?
Andrea
Andrea16h ago
Did you obtain your alias workaround by referencing this stack overflow ? Unfortunately it is still the case that predicates still cannot take traversals.
Stack Overflow
Gremlin comparing two properties of a single node
Given below mentioned dataset, how do I check TotalPay of the employee where totalPay is variablePay + FixedPay What percentage variable pay is to TotalPay If totalPay is less than 100,000 g.addV('
marti.sant
marti.santOP16h ago
Yep! I was looking for alternatives because I was hoping to simplify some of the querying I do that involves comparisons between node properties for a personal project. I could only really find that stack overflow post and wasn't sure if there's an alternative that doesn't include aliasing.
Andrea
Andrea14h ago
Unfortunately not for now

Did you find this page helpful?