I am trying to understand the conceptual difference of doing two consecutive or separately made versus to put all the conditions inside one or. I am yielding different values by doing this:
Doing the or separately :
g.V(1).in('linked_to', 'used_by')
.or(has('type', 'knows'), has('type', 'like'), has('type','follows'))
.or(hasNot('last_used'), has('last_used',gt(datetime('2021-09-07T10:04:05.000Z'))))
.out('linked_to', 'used_by')
.dedup()
vs including the or inside one same or
g.V(1).in('linked_to', 'used_by')
.or(has('type', 'knows'), has('type', 'like'), has('type','follows') , hasNot('last_used'), has('last_used',gt(datetime('2021-09-07T10:04:05.000Z'))))
.out('linked_to', 'used_by')
.dedup()
You really do not need an or
step here for several of the tests. You can just use within
instead and wrap the remaining steps inside an or
. Note that hasNot(key)
can be an expensive filter as you are testing for the non existence of something on every vertex being tested which may not be something an index helps with. For example:
g.V(1).
in('linked_to', 'used_by').
or(has('type', within('knows', 'like', 'follows')),
hasNot('last_used'),
has('last_used',gt(datetime('2021-09-07T10:04:05.000Z'))))