While helping someone with a Gremlin query this week, I was reminded that Gremlin semantics can be a little subtle at times. I used the example below to show a case where two queries at first may look like they will generate the same results but in fact do not. This would be a nice example to add somewhere in the text.
// Total node count
gremlin> g.V().count()
==>3747
// How many nodes have a city?
gremlin> g.V().has('city').count()
==>3502
// The property must exist to be considered
gremlin> g.V().has('city',neq('I-do-not-exist')).count()
==>3502
// The property does not have to exist
gremlin> g.V().not(has('city',eq('I-do-not-exist'))).count()
==>3747
Two queries that look the same but are different
While helping someone with a Gremlin query this week, I was reminded that Gremlin semantics can be a little subtle at times. I used the example below to show a case where two queries at first may look like they will generate the same results but in fact do not. This would be a nice example to add somewhere in the text.