0
votes

I have a graph with the following structure:

|-ProductFit
|-|-Part
|-|-App
|-|-|-ProductID
|-|-|-ProductModelID
|-|-|-ProductYearID

|-ProductID
|-|-ProductName
|-|-ProductModelID
|-|-ProductYearID

|-ProductModelID
|-|-ProductModelName

|-ProductYearID
|-|-ProductYear

where ProductFit is my first independent vertex and ProductID, ProductModelID and ProductYearID as my connected vertices.

Now, there are some fields of ProductID's in ProductFit having wrong values for which I need to get values from other vertex of ProductID.

Here is my query:

g.V().has('ProductFit','Part','PA01').properties('App')
.valueMap('ProductID','ProductModelID','ProductYearID')
.choose(values('ProductModelID'))
.option(PM01, g.V().has('ProductFit','Part','PA01').properties('App').values('ProductModelID'))
.option(PM02, g.V().has('ProductID','ProductModelID','PM01'))
.values('ProductModelID')

But this is giving me this error:

java.util.HashMap cannot be cast to org.apache.tinkerpop.gremlin.structure.Element

Is it that I can't go from one vertex to other during traversal or is there some problem in query? TIA.

1

1 Answers

3
votes

Your choose() is using values() which is not meant to pick values out of a Map. It is meant to be used with an Element. I get the same error on The Crew toy graph:

gremlin> graph = TinkerFactory.createTheCrew()
==>tinkergraph[vertices:6 edges:14]
gremlin> g = graph.traversal()
==>graphtraversalsource[tinkergraph[vertices:6 edges:14], standard]
gremlin> g.V().properties('location').valueMap().choose(values('startTime')).option(2004,constant(1)).option(none,constant(2))
java.util.HashMap cannot be cast to org.apache.tinkerpop.gremlin.structure.Element
Type ':help' or ':h' for help.
Display stack trace? [yN]n

You should instead use select:

gremlin> g.V().properties('location').valueMap().choose(select('startTime')).option(2004,constant(1)).option(none,constant(2))
==>2
==>2
==>1
...
==>2