从OrientDb中的图查找子图

时间:2018-10-09 19:17:23

标签: graph neo4j orientdb gremlin tinkerpop

这是我的图

[Person] -livesIn->  [City]
[Factory] -locatedIn-> [City]
[Person] -worksAt-> [Factory]

我如何找到必须上班的人。即“在不住在他们所居住城市的工厂工作的人”。?

我试图这样做:

Match 
    {class:Person, as: person} -worksAt-> {class:Factory, as: factory} -locatedIn-> {class:City, as: city},
    {how do i check, person !livesIn city }
return person

我认为这个问题不是orinentDb特有的,所以请随时告诉我如何在其他任何graphDb中解决此问题。

我也熟悉OrientDb和Gremlin的SQL方言。 非常感谢您使用任何一种语言提供的指导/帮助。

1 个答案:

答案 0 :(得分:0)

尝试一下:

Match 
    {class:Person, as: person} -worksAt-> {class:Factory, as: factory} -locatedIn-> {class:City, as: city, where: (in("locatedIn").name <> name)}
return person.name as person

这是输出:

enter image description here

如您所见,只有约翰被退回:

enter image description here


希望对您有帮助

致谢