Gremlin 忽略商店价值
Gremlin ignoring store value
我是 gremlin 的新手,正在尝试查询,但据我观察,存储值总是被忽略
我也试过 store
、aggregate
和 as
,但都给我错误的值。
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))))
现在得到空结果。
编辑:
我也对打印动态值作为副作用有疑问
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 查询的最佳做法是什么?
有些东西在您的遍历中不起作用。首先,.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)))
我是 gremlin 的新手,正在尝试查询,但据我观察,存储值总是被忽略
我也试过 store
、aggregate
和 as
,但都给我错误的值。
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))))
现在得到空结果。
编辑:
我也对打印动态值作为副作用有疑问
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 查询的最佳做法是什么?
有些东西在您的遍历中不起作用。首先,.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)))