Search code examples
scalagraph-databasesgremlintinkerpopgremlin-server

select multiple edge property values from list of edges and put in list[List]


I am having vertices with multiple edges having same labels. Edges having properties like age1,age2 and time in it.

Example:

A-->B => age1 = 10, age2=10 and time = t1

A-->B => age1 = 20, age2=30 and time = t1

A-->B => age1 = 30, age2=50 and time = t1

I need to form two list[List[]] with the above the edges with specific time

eg : List[[10,10][20,30][30,50]]

graph.traversal.V().has(ID,"A").bothE("interference").
where(_.values("time").is(P.gt("sometime"))).values("age1").as("x").values("age2").as("y").select("x","y").toList()

It is giving some compilation error. Am i doing something wrong in the query

Compilation Error:

could not find implicit value for parameter p: shapeless.ops.hlist.Prepend[shapeless.HNil,shapeless.::[A,shapeless.HNil]] .where(_.values("time").is(P.gt(endtime))).values("age1").as("x")


Solution

  • Below solves this problem

    Scala gremlin:

     graph.traversal.V().has(ID,"A").bothE("interference").
        where(_.values("time").is(P.gt("sometime"))).valueMap("age1","age2").toList()
    

    Gremlin console:

    graph.traversal().V().has('ID', 'a').bothE("interference").valueMap('age1','age2')
    ==>{age2=50, age1=10}
    ==>{age2=50, age1=30}
    ==>{age2=20, age1=60}