Janusgraph using Gremlin query in .net core 3.0

孤者浪人 提交于 2020-04-29 03:28:46

问题


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.


回答1:


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())


来源:https://stackoverflow.com/questions/60263542/janusgraph-using-gremlin-query-in-net-core-3-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!