【发布时间】:2017-09-10 17:26:26
【问题描述】:
我使用 gremlin-python 推送数据。现在我想对它运行特定的查询。我正在为此使用 Gizmo。
我基本上是想达到每个节点的中心度。我该怎么做?
目前我查询返回的结果与:
g.V().group().
......1> by(id).
......2> by(union(__(), outE('mentions').count()).fold())
我是如何做到这一点的:
def query(self, q):
from gizmo import Mapper, Request
from gremlinpy import Gremlin
req = Request('localhost', 8182)
gremlin = Gremlin('g')
mapper = Mapper(request=req, gremlin=gremlin)
# s = mapper.gremlin.V().inE('mentions').count().toList()
# res = mapper.query(gremlin=s)
# print(res.get_data()[0])
print("Something")
res = mapper.query(script=q)
# print(res.get_data()[0])
print("Something")
print(res.data)
print(res.first(), res.data)
# exit(0)
return res.first()
我想要的是显示在 res 变量中获取的数据。
但每次我得到错误时:
AttributeError: 'coroutine' object has no attribute 'data'
AttributeError: 'coroutine' object has no attribute 'get_data'
或者我尝试过的任何类似的东西。
如何获取从协程对象中获取的结果?
注意:我传递给函数 query() 的示例查询是 g.V().count()
还有其他更好的方法可以在 gremlin shell 中从 python 运行任何通用查询并获取结果吗?
图形数据库: JanusGraph
后端: Cassandra
索引后端: Elasticsearch
【问题讨论】:
标签: python graph gremlin janusgraph