Search code examples
graphpattern-matchingorientdb

OrientDB deep traversal until specific class


So I have simple graph. The most left nodes are 'Team' class. The second most right (gray one) is 'Sport' class node.

SimpleGraph

I need to find all Teams which relates to specific Sport

When I have only one Team node this query works:

MATCH {class:Team, as: team} --> {class: Sport, maxDepth: 10}
RETURN team.Abbreviation

After I've added second node of 'Team' class I've started to get this error:

java.lang.RuntimeException: Invalid pattern to match!

If I remove 'maxDepth' it works but returns nothing

What should I do to make it work?


Solution

  • It's definitely a bug, I'm checking it. As a quick work-around you can add a condition to the first element in the pattern, so that you force the executor to start from there:

     MATCH {class:Team, as: team, where:(true)} --> {class: Sport, maxDepth: 10}
     RETURN team.Abbreviation
    

    Even better, remove the "class" from the right hand:

     MATCH {class:Team, as: team} --> {where: (@class = 'Sport'), maxDepth: 10}
     RETURN team.Abbreviation
    

    The problem here is that the pattern is being evaluated in the wrong direction (from right to left), with the above work-around you are forcing OrientDB to evaluate it from left to right