Reputation: 1164
I am trying to fetch edge property value between two vertices. E.g. A-->B A and B are two vertices and it has edge with property(name).
My code looks like:
graph.V().hasLabel(A).outE().value("name").headOption()
It gives me the property value for name.
In a given two vertices, i am getting None as output
graph.traversal().V().hasLabel(A).outE("test").outV().hasLabel(B).properties("name").headOption()
'test' - Edge Label 'name' - Edge property
Any idea what is wrong with my query.
Upvotes: 1
Views: 402
Reputation: 3565
Apologies for not being able to answer this in your comments on the previous question you asked. I think what you are looking for is:
graph.traversal().V()
.hasLabel("A").outE("test").as("x").otherV()
.hasLabel("B").select("x").properties("name");
If you just want the values of the properties on the edge you can do the following:
graph.traversal().V()
.hasLabel("A").outE("test").as("x").otherV()
.hasLabel("B").select("x").values("name");
Side Note (Why is your original traversal wrong): Your original traversal:
graph.traversal().V().hasLabel(A).outE("test").outV().hasLabel(B).properties("name").headOption()
is doing the following:
Get all vertices with the label "A"
From those vertices follow the outward going edges which have the label "test"
to vertices which have the label "B"
Then get the property "name"
from those vertices
You are actually asking for the properties on the vertex.
Upvotes: 1