Using the IMDB dataset example, suppose we have to find out all the persons connected to the movie “The Princess Bride”. The persons may be connected to the movie “The Princess Bride” node by different edges like the actor, director etc.
We can write the query in cypher like:
MATCH (p:Person)–>(m:movie { title: ‘The Princess Bride’ }) RETURN p.name
{
q(func: type(Person)) @filter(eq(name, "Devin Townsend")) @cascade {
name
movie @filter(eq(name, "Devin Townsend"))
}
}
But I’m not sure about this neo4j query. It doesn’t have and specified edge. So in Dgraph that could mean a recurse query.
{
q(func: type(Person)) @filter(eq(name, "Devin Townsend")) @cascade @recurse {
name
movie @filter(eq(name, "Devin Townsend")) #One of these gonna be true
film @filter(eq(name, "The Princess Bride’"))
liked @filter(eq(name, "The Princess Bride’"))
watched @filter(eq(name, "The Princess Bride’"))
rated @filter(eq(name, "The Princess Bride’"))
}
}
Thanks @MichelDiz for clarifying my doubts. In RedisGraph or Neo4j we can do that without specifying the edge name. (p:Person)–>(m:movie { title: ‘The Princess Bride’ }) this returns all the Person nodes which are connected to the movie node with title: ‘The Princess Bride’ by any edge. That’s why I was confused whether Dgraph also has the same functionality.