database - Gremlin 忽略存储价值
问题描述
我是 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
我希望 size 的值'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 查询的最佳实践是什么?
解决方案
在您的遍历中,有些事情是行不通的。首先,.size()
不是 Gremlin 步骤,您可能正在寻找.count(local)
. 接下来,eq()
不采用动态值,它仅适用于常量值。阅读文档以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)))
推荐阅读
- android - 未找到 Android 数据绑定属性
- angular - alternatively change selection of values
- maven - SNAPSHOT-被快照构建覆盖的开发 jar
- amazon-web-services - AWS sdk cloudwatch GetMetricWidgetImage:图像中未显示结果
- git - Jenkins Git 插件客户端不使用发布者的凭据
- javascript - 如何更改蜘蛛网图表中单点的颜色
- python - 如何使硒浏览器和手动打开的浏览器具有相同的行为?
- python - 如何使用新鲜番茄模板将数据从 excel 文件导入和读取到 Python 电影中心
- amazon-web-services - API Gateway 中 AWS Firehose PutRecordBatch 的映射模板应该是什么样的?
- java - 当您在 Firebase 上使用 .setPersistenceEnabled(true) 时,真的需要 .addOnCompleteListener 吗?