I am trying to build a query that will return a Vertex both edges, and sort them conditionally by value of a different property according to whether the original Vertex is the out Vertex or in Vertex in the given edge, I have two properties that will comply with this sort ("origin_pinned" & "target_pinned"), if an edge in Vertex is the original vertex I want to use "origin_pinned" value if its the out vertex then I want to use "target_pinned" value
This must be one query
I tried to run the following query but does not seem to have effect:
g.V('id123').bothE().order().by(values(choose(inV().is(V('id123')),
constant('origin_pinned'), constant('target_pinned'))), desc)
2
Answers
managed to figure it out with the help of Kelvin Lawrence's answer:
The
values
step will not work the way you are trying to use it. You did not include any sample data in the question, but using the air-routes data set, the query can most likely be simplified as shown below:and to prove the reverse also works
To check things are working as expected, we can do: