简体   繁体   English

Gremlin忽略了商店的价值

[英]Gremlin ignoring store value

I am new to gremlin and trying out a query but as I observe store value is always ignored 我是gremlin的新手,正在尝试查询,但是我观察到存储值始终被忽略

I have tried store , aggregate and as as well but all are giving me false values. 我也尝试过storeaggregateas但是所有人都给了我错误的值。

gV().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()))))

this gives size of 'xm' as always 0 这使'xm'大小始终为0

I expect the value of size 'xm' to be equal to the number of outgoing edges from each avro_schema with the edge label as '__avro_record.fields' 我希望大小'xm'的值等于每个avro_schema的出站边缘数,且边缘标签为'__avro_record.fields'

As pointed,changed the query to : 如前所述,将查询更改为:

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

Now getting empty results. 现在得到空结果。

Edit : 编辑:

Also I have doubts related to printing of dynamic values as sideEffect 我也怀疑与将动态值打印为副作用有关

gV().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))))

Output: 输出:

[CountLocalStep]

Where as I expect the actual value of count(local).What is the best practice to debug gremlin query? 我期望count(local)的实际值在哪里。调试gremlin查询的最佳实践是什么?

There are a few things that won't work in your traversal. 有一些事情在您的遍历中不起作用。 First, .size() is not a Gremlin step, you're probably looking for .count(local) . 首先, .size()不是Gremlin步骤,您可能正在寻找.count(local) Next, eq() does not take dynamic values, it only works with constant values. 接下来, eq()不接受动态值,它仅适用于常量值。 Read the docs for where() step to learn how to compare against dynamic values. 阅读文档,了解where()步骤,以了解如何与动态值进行比较。

UPDATE 更新

To compare the two count() values you would do something like this: 要比较两个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)))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM