【问题标题】:TinkerPop: Filter by Edge not connected with an EdgeTinkerPop:按未连接边缘的边缘过滤
【发布时间】:2018-04-30 05:29:51
【问题描述】:

示例数据库:TinkerPop Modern


目标:寻找没有开发过软件的人。

即。不直接连接到顶点类型“软件”的顶点类型“人”

连接到软件的人 [作品]

g.V().hasLabel("Person").as("from")
.project("title", "node")
    .by(select("from").unfold().values("name").fold())
    .by(select("from").unfold().label().fold())

查找未连接到软件的人员 [不起作用]

g.V().hasLabel("Person").as("from")
.filter(both().not(hasLabel("Software")))
.project("title", "node")
    .by(select("from").unfold().values("name").fold())
    .by(select("from").unfold().label().fold())

我相信它忽略了不满足条件但不跳过顶点的边缘。

试图做一个循环,但没有找到一个例子。

Cypher Query 等效项(仅供参考):MATCH (n:People) WHERE NOT (n)--(:Software) RETURN n


示例数据库:

【问题讨论】:

标签: gremlin tinkerpop3


【解决方案1】:

我相信你只需要改变你的过滤条件:

gremlin> g.V().hasLabel('person').
......1>   filter(__.not(outE('created'))).
......2>   project("title", "node").
......3>     by('name').
......4>     by(label)
==>[title:vadas,node:person]

如您所见,您也无需出于任何原因选择回到该as() 步骤 - 您已经将该顶点作为project() 中的当前遍历器。

【讨论】:

  • 它有效:D 谢谢...现在我只是想弄清楚为什么我的语法失败了
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-07-16
  • 2019-03-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多