In attempting to perform OR-like operations in a where() step applied to a match(), I stumbled on some discrepancies between match() and select().
The following traversals work as expected:
> g.inject([1,1], [1,2]).as("list").
match(
__.as("list").unfold().limit(1).as("head"),
__.as("list").unfold().tail().as("tail")
)
==>[head:1, tail:1, list:[1,1]]
==>[head:1, tail:2, list:[1,2]]
> g.inject([1,1], [1,2]).as("list").
match(
__.as("list").unfold().limit(1).as("head"),
__.as("list").unfold().tail().as("tail")
).where("head", eq("tail"))
==>[head:1, tail:1, list:[1,1]]
If I insert an or() step around the where() then the returned map is missing the key "list":
> g.inject([1,1], [1,2]).as("list").
match(
__.as("list").unfold().limit(1).as("head"),
__.as("list").unfold().tail().as("tail")
).or(where("head", eq("tail")))
==>[head:1, tail:1]
Perhaps even more bizarre is the effect of identity():
> g.inject([1,1], [1,2]).as("list").
match(
__.as("list").unfold().limit(1).as("head"),
__.as("list").unfold().tail().as("tail")
).identity()
==>[]
==>[]
If or() is a filter step and identity is a nop, then shouldn't both leave the traversers that pass unaltered?
If I do a select() after the match(), I get back to the expected result, whether or not I use an or()/identity():
> g.inject([1,1], [1,2]).as("list").
match(
__.as("list").unfold().limit(1).as("head"),
__.as("list").unfold().tail().as("tail")
).select("list", "head", "tail").or(where("head", eq("tail")))
==>[list:[1,1], head:1, tail:1]
It is my understanding that match() and select() should both produce a Map<String, Object>, and in the example above those key/value pairs should be identical in both. The fact that identity()/or(where(…)) behaves differently in each case seems like there may be a bug, else I have fundamentally misunderstood something.
I am using Tinkerpop 3.4.8.
Any insight would be much appreciated.
Jim