.NET Core 3.0中使用Gremlin查询的Janusgraph [英] Janusgraph using Gremlin query in .net core 3.0

查看:139
本文介绍了.NET Core 3.0中使用Gremlin查询的Janusgraph的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们当前在Net Core 3.0应用程序中使用gremlin.net库连接到Janusgraph数据库.

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

我们需要在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')

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

只要我们没有inV()部分,查询就可以正常运行.如果我们有inV(),我们将面临以下错误, ScriptEvaluationError: java.util.LinkedHashMap cannot be cast to org.apache.tinkerpop.gremlin.structure.Edge

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. 有没有一种方法可以运行/重写此查询而不将其分成两个部分? janusgraph的新手,在Cosmos db中可以正常工作.
  2. 根据 stackoverflow ,我知道存在自定义反序列化参与janusgraph.我曾尝试过,但仍然无济于事.有人可以发布可以在.net core 3.0中添加自定义反序列化的工作代码吗.
  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.

举一个简单的例子,查询g.V(1).as('v').outE().limit(1).as('e').select('v','e')直接在gremlin控制台中工作,但不适用于janusgraph的gremlin.net库(groovy-string).我们已经在服务器中尝试了GRYO和GraphSON Serializer设置.我们可以使用groovy-string,因为这是现有应用程序.

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.

推荐答案

只要我们没有inV()部分,查询就可以正常运行.如果我们拥有inV(),我们将面临以下错误ScriptEvaluationError

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

您不能拥有inV(),因为它紧随valueMap(). inV()旨在从Edge对象遍历到其传入的Vertex,但是valueMap()Edge转换为Map,因此您将得到以下错误:"java.util.LinkedHashMap不能为投射到org.apache.tinkerpop.gremlin.structure.Edge"

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"

我想你只是想要

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

这篇关于.NET Core 3.0中使用Gremlin查询的Janusgraph的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆