I am using OrientDB 'match' to get a path (on the graph) according to a criteria, but I get a result path that doesn't exist.
I have a "Person" vertex that has a "PhoneCall" edge to another "Person" vertex - only one path should be a match! so I expext to get as a result: vertex1-edgeX-vertex2 For example - "jonn Smith --phoneCallX-- dan smith"
What I actually get is 2 pathes:
The query:
MATCH {class:person, as:E1, where:( ( firstName IN ['John'] ) )}.bothE(){class:phoneCall, as:R0}.bothV(){class:person, as:E0, where:( ( lastName IN ['Smith'] ) )} RETURN $paths
I think it is happening because of the "both()" method with the fact that the first vertex apply to both filters:
But still - I meant to find all paths of "John-phoneCall-Smith" and I got an edge (that doesn't exist) between this John to himself just because his name is Smith (which should be the condition of the OTHER entity of this relation) )
Please help me - what do I do wrong?
You can explicitly specify that the two vertices have to be different.
The syntax is, in the WHERE condition of E2, $matched.E1 <> $currentMatch
MATCH
{class:person, as:E1, where:( ( firstName IN ['John'] ) )}
.bothE(){class:phoneCall, as:R0}
.bothV(){class:person, as:E0, where:(lastName IN ['Smith'] AND $matched.E1 <> $currentMatch)}
RETURN $paths