【问题标题】:following parametered script in java is not supported?why?不支持以下 java 中的参数化脚本?为什么?
【发布时间】:2020-12-25 11:35:49
【问题描述】:

我将参数化脚本发送到远程 gremlin-server,但有些脚本成功,有些脚本错误。

比如下面的testcase是成功的,gremlin服务器返回期望的结果

List<Long> ids = Lists.newArrayList(19496288L, 40076200L, 8717992L, 36070256L, 39303024L, 53232552L);
Map<String, Object> parameters = new HashMap<>();
parameters.put("ids1", ids);
parameters.put("ret", new String[]{"linkid", "locnwid", "remnwid"});

String strIds = "19496288,40076200,8717992,36070256,39303024,53232552";
String script = String.format("g.V(ids1).outE('L2_LINK').where(otherV().hasId(%s)).valueMap(ret).by(unfold())", strIds)
// this query script is also ok
// String.format("g.V().hasId(ids1).outE('L2_LINK').where(otherV().hasId(%s)).valueMap(ret).by(unfold())", strIds)
client.submit(script, parameters).all().get()

但是下面的测试用例是错误的,gremlin 服务器什么也没返回

List<Long> ids = Lists.newArrayList(19496288L, 40076200L, 8717992L, 36070256L, 39303024L, 53232552L);
Map<String, Object> parameters = new HashMap<>();
parameters.put("ids1", ids);
parameters.put("ret", new String[]{"linkid", "locnwid", "remnwid"});

String strIds = "19496288,40076200,8717992,36070256,39303024,53232552";
String script = String.format("g.V(%s).outE('L2_LINK').where(otherV().hasId(ids1)).valueMap(ret).by(unfold())", strIds)

client.submit(script, parameters).all().get()

我的第二个查询脚本有什么问题吗?如何解决?

另一个问题:

我想查询连接组中节点的边,节点数超过255,如何构造查询脚本一次搜索得到边?

【问题讨论】:

    标签: gremlin janusgraph gremlin-server


    【解决方案1】:

    经过多次尝试,以下脚本可以工作,但我不知道为什么。

    String script = String.format("g.V(ids1).outE('L2_LINK').where(otherV().id().is(within(ids1))).valueMap(ret).by(unfold())", strIds)
    

    【讨论】:

      猜你喜欢
      • 2021-11-05
      • 2011-10-17
      • 1970-01-01
      • 2017-01-21
      • 1970-01-01
      • 2021-11-06
      • 2018-10-11
      • 1970-01-01
      相关资源
      最近更新 更多