简体   繁体   中英

Gremlin ignoring store value

I am new to gremlin and trying out a query but as I observe store value is always ignored

I have tried store , aggregate and as as well but all are giving me false values.

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

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'

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?

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) . Next, eq() does not take dynamic values, it only works with constant values. Read the docs for where() step to learn how to compare against dynamic values.

UPDATE

To compare the two count() values you would do something like this:

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)))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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