Gremlin API - joining on predicate values


#1

Looking at the Gremlin API: Javascript / Gremlin API

Currently, joining works on shared nodes.

I think it would be useful to join on specified predicates or values, for example

var cFollows = g.V("charlie").Out("follows")
var dFollows = g.V("dani").Out("follows")
// People followed by both charlie (bob and dani) and dani (bob and greg) -- returns bob.
cFollows.Intersect(dFollows)
// Equivalently, g.V("charlie").Out("follows").And(g.V("dani").Out("follows"))

would not work if the nodes for each path are different ‘types’.

ie if cFollows was a morphism with nodes/path of type A predicate Ap with a value of Av and i wanted to return all A nodes that intersect with nodes/path of type B which have a predicate Bp with a value Bv which matches Av.

The argument is similar for union and except.

for example

charlie follows bob .
dani follows jen .
jen is tall .
bob is short .

A query might look like this

var cFollows = g.V("charlie").Out("follows")
var dFollows = g.V("dani").Out("follows")
// of the people charlie and dani follow, who is tall?
cFollows.Intersect(dFollows, "is", "tall")

This should come back with
{
id: ‘jen’
}

Does anyone else think this would be useful?


#2

Looking at the example, it seems like .Has("is", "tall") should do the trick. Am I missing something here?


#3

I will see if i can combine two paths and then apply a has() on the result. Thanks!