Reputation: 5249
I'm trying to get a property value of an edge given source and dest vertex ids, and edge label.
in the gremlin terminal the following worked:
g.V("fromNodeId").outE("edgeLabel").where(inV().hasID("toNodeID")).values("edgeProp")
sadly, in groovy, the inV() and hasID() aren't recognized, and i can't find the correct import to get it to work.
here are the imports iv'e tried:
import org.apache.commons.configuration.Configuration;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource
import org.apache.tinkerpop.gremlin.process.*
import org.apache.tinkerpop.gremlin.groovy.*
import org.apache.tinkerpop.gremlin.groovy.function.*
import org.apache.tinkerpop.gremlin.groovy.util.*
import org.apache.tinkerpop.gremlin.pipes.filter.*
import org.apache.tinkerpop.gremlin.structure.Edge
import org.apache.tinkerpop.gremlin.structure.Vertex
import org.apache.tinkerpop.gremlin.structure.EdgeTest;
import org.apache.tinkerpop.gremlin.structure.Graph
i'll note that other queries s.a. the following work just fine:
String getPropValueByID(Long id, String prop){
def result = []
**g.V(id).values(prop).fill(result)**
if(result.empty) return null
return result.first()
}
Upvotes: 0
Views: 474
Reputation: 6792
This is described in the TinkerPop3 documentation
To reduce the verbosity of the expression, it is good to
import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.*
. This way, instead of doing__.inE()
for an anonymous traversal, it is possible to simply writeinE()
. Be aware of language-specific reserved keywords when using anonymous traversals. For example, in and as are reserved keywords in Groovy, therefore you must use the verbose syntax__.in()
and__.as()
to avoid collisions.
Upvotes: 2