如何使用 Gremlin npm 包中的 sideEffect() 方法
How do you use the sideEffect() method in the Gremlin npm package
我试过各种调用sideEffect()的方法,但是none都有效,网上找不到文档和例子,源码有点抽象,看不懂无需花费相当长的时间查看它。
举个例子:
const y = await g.V().hasId('a4b64522-9cda-1b34-8f76-634242933a0d').sideEffect('drop()').next();
结果
Error: Server error: {"requestId":"8915089a-cde3-4861-b73a-2534cefbc0b2","code":"InternalFailureException","detailedMessage":"Could not locate method: NeptuneGraphTraversal.sideEffect([drop()])"} (599)
我 运行 这些针对 AWS Neptune 的遍历以防万一(尽管 运行 通过 Python 和针对 Neptune 的 Gremlin 控制台的类似查询工作)。
sideEffect()
步骤采取 anonymous traversal so the syntax I provided in your 应该在每个 Gremlin 语言变体中同样有效,包括 javascript:
g.V().hasId('a4b64522-9cda-1b34-8f76-634242933a0d').sideEffect(drop())
drop()
当然是从 __
产生的,应该是你的 standard imports 的一部分,可以更明确地称为:
const __ = gremlin.process.statics;
g.V().hasId('a4b64522-9cda-1b34-8f76-634242933a0d').sideEffect(__.drop())
您在问题中描述的错误仅与您将 drop()
作为字符串值传递的用法有关。也就是说,我想海王星可能根本不支持 sideEffect()
作为一个步骤?您可以使用合法语法使用更简单的遍历来测试它,看看您是否遇到相同的错误:
g.V().hasId('a4b64522-9cda-1b34-8f76-634242933a0d').sideEffect(__.constant(1))
如果该遍历 returns 具有您正在查询的指定 ID 的 Vertex
并且您没有看到错误,那么我认为 sideEffect()
是受支持的步骤。也许有更多 Neptune 经验的人能够为您提供更官方的答案。
我试过各种调用sideEffect()的方法,但是none都有效,网上找不到文档和例子,源码有点抽象,看不懂无需花费相当长的时间查看它。
举个例子:
const y = await g.V().hasId('a4b64522-9cda-1b34-8f76-634242933a0d').sideEffect('drop()').next();
结果
Error: Server error: {"requestId":"8915089a-cde3-4861-b73a-2534cefbc0b2","code":"InternalFailureException","detailedMessage":"Could not locate method: NeptuneGraphTraversal.sideEffect([drop()])"} (599)
我 运行 这些针对 AWS Neptune 的遍历以防万一(尽管 运行 通过 Python 和针对 Neptune 的 Gremlin 控制台的类似查询工作)。
sideEffect()
步骤采取 anonymous traversal so the syntax I provided in your
g.V().hasId('a4b64522-9cda-1b34-8f76-634242933a0d').sideEffect(drop())
drop()
当然是从 __
产生的,应该是你的 standard imports 的一部分,可以更明确地称为:
const __ = gremlin.process.statics;
g.V().hasId('a4b64522-9cda-1b34-8f76-634242933a0d').sideEffect(__.drop())
您在问题中描述的错误仅与您将 drop()
作为字符串值传递的用法有关。也就是说,我想海王星可能根本不支持 sideEffect()
作为一个步骤?您可以使用合法语法使用更简单的遍历来测试它,看看您是否遇到相同的错误:
g.V().hasId('a4b64522-9cda-1b34-8f76-634242933a0d').sideEffect(__.constant(1))
如果该遍历 returns 具有您正在查询的指定 ID 的 Vertex
并且您没有看到错误,那么我认为 sideEffect()
是受支持的步骤。也许有更多 Neptune 经验的人能够为您提供更官方的答案。