Raj
Raj

Reputation: 359

Janusgraph using Gremlin query in .net core 3.0

We currently use gremlin.net library in a net core 3.0 application to connect to Janusgraph db.

We need to execute below query in janusgraph g.V('12345').outE('myedge').has('datetime',lt(1581922847)).order().by('datetime', incr).limit(100).valueMap().as('time').inV().as('user').select('time','user')

The query runs fine as long as we dont have inV() part. If we have inV(), we are facing below error, ScriptEvaluationError: java.util.LinkedHashMap cannot be cast to org.apache.tinkerpop.gremlin.structure.Edge

  1. Is there a way to run/rewrite this query without splitting it into two? Am new to janusgraph and this works fine in Cosmos db.
  2. As per stackoverflow, I understand there is a custom deserialization involved in janusgraph. I tried that, but still doesn't help me. Can someone, post a working code that adds a custom deserialization in .net core 3.0.

To have a simpler example, the query g.V(1).as('v').outE().limit(1).as('e').select('v','e') works directly in gremlin console but not with gremlin.net library(groovy-string) for janusgraph. We have tried both GRYO and GraphSON Serializer settings in server. We are in a position to use groovy-string as this is an existing application.

Upvotes: 0

Views: 400

Answers (2)

ProgC
ProgC

Reputation: 25

I would use the JanusGraph.Net nuget package! since there are JanusGraph-specific types that Gremlin.Net can't serialize.

Upvotes: 1

stephen mallette
stephen mallette

Reputation: 46226

The query runs fine as long as we dont have inV() part. If we have inV(), we are facing below error, ScriptEvaluationError

You can't have inV() because it follows valueMap(). inV() is meant to traverse from an Edge object to its incoming Vertex, but valueMap() converts the Edge to a Map and you thus get the error of: "java.util.LinkedHashMap cannot be cast to org.apache.tinkerpop.gremlin.structure.Edge"

I think you just want:

g.V('12345').
  outE('myedge').has('datetime',lt(1581922847)).
  order().by('datetime', incr).
  limit(100).
  project('time','user').
    by(valueMap()).
    by(inV())

Upvotes: 3

Related Questions