Gremlin忽略了商店的价值

时间:2019-09-13 14:26:31

标签: database groovy graph gremlin

我是gremlin的新手,正在尝试查询,但是我发现商店价值始终被忽略

我也尝试过storeaggregateas,但都给了我错误的值。

g.V().has('__typeName','avro_schema').where(local(out('__avro_record.fields').as('xm').local(out('classifiedAs').has('__typeName', 'DataClassification').count().is(eq(1))).count().is(eq(select('xm').size()))))

这使'xm'的大小始终为0

我希望大小'xm'的值等于边缘标签为avro_schema的每个'__avro_record.fields'的输出边缘的数量

如前所述,将查询更改为:

g.V().has('__typeName','avro_schema').where(local(out('__avro_record.fields').local(out('classifiedAs').has('__typeName', 'DataClassification').count().is(eq(1))).count().is(count(local))))

现在得到空结果。

编辑:

我也怀疑将动态值打印为sideEffect

g.V().has('__typeName','avro_schema').where(local(out('__avro_record.fields').local(out('classifiedAs').has('__typeName', 'DataClassification').count().is(eq(1))).count().sideEffect{ println count(local) }.is(count(local))))

输出:

[CountLocalStep]

我期望count(local)的实际值在哪里。调试gremlin查询的最佳实践是什么?

1 个答案:

答案 0 :(得分:1)

有些事情在遍历中不起作用。首先,.size()不是Gremlin步骤,您可能正在寻找.count(local)。接下来,eq()不采用动态值,它仅适用于常量值。阅读docs for where()步骤,了解如何与动态值进行比较。

更新

要比较两个count()值,您可以执行以下操作:

g.V().has('__typeName','avro_schema').filter(
    out('__avro_record.fields').fold().as('x').
    map(unfold().
        out('classifiedAs').has('__typeName', 'DataClassification').fold()).as('y').
    where('x', eq('y')).
      by(count(local)))