首页 > 解决方案 > Gremlin-Python:属性存在检查

问题描述

我似乎无法找到一种惯用的方法来过滤具有或不具有特定属性(无论其值如何)的节点。

属性存在:

> g.V().hasNot('weight', None).toList()
*** gremlin_python.driver.protocol.GremlinServerError: 599: Could not locate method: DefaultGraphTraversal.hasNot([weight, null])

属性不存在:

> g.V().has('weight', None).toList()
*** gremlin_python.driver.protocol.GremlinServerError: 599: null:has([weight, null])

hasKey()不返回结果:

> g.V().hasKey('weight')

使用 gremlin-server 3.3.4

标签: gremlintinkerpop3

解决方案


哦,原来这行得通:

g.V().has('weight')

在文档中很难找到:http: //tinkerpop.apache.org/docs/current/reference/#has-step


推荐阅读