[英]Gremlin Python Gizmo how to query in graph db
I've pushed data using gremlin-python. 我使用gremlin-python推送数据。 Now I want to run spcific queries on it.
现在我想对它运行特定的查询。 I'm using gizmo for that.
我正在使用Gizmo。
I basically want to achieve the degree of centrality for each node. 我基本上想要达到每个节点的中心度。 How do I do that?
我怎么做?
Currently I've query to return the same as : 目前我查询返回相同的:
g.V().group().
......1> by(id).
......2> by(union(__(), outE('mentions').count()).fold())
How I'm achieving that is: 我是如何实现的:
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()
What I want is to display the data fetched inside res variable. 我想要的是显示res变量中获取的数据。
But each time I get errors as : 但每次我收到错误时:
AttributeError: 'coroutine' object has no attribute 'data'
AttributeError: 'coroutine' object has no attribute 'get_data'
or anything similar which I try. 或者我试过的任何类似的东西。
How do I fetch the results fetched from coroutine object? 如何获取从coroutine对象获取的结果?
NOTE : The sample query I'm passing to function query() is gV().count() 注意 :我传递给函数query()的示例查询是gV()。count()
Is there any other better way to run any generic queries from python in gremlin shell and fetch results? 有没有更好的方法在gremlin shell中运行python中的任何泛型查询并获取结果?
Graph DB: JanusGraph 图DB: JanusGraph
Backend: Cassandra 后端:卡桑德拉
Indexing Backend: Elasticsearch 索引后端: Elasticsearch
You mention gizmo which could relate to multiple projects, but I think you mean this one: 你提到了可能涉及多个项目的小发明,但我认为你的意思是这个:
https://github.com/emehrkay/gizmo https://github.com/emehrkay/gizmo
According to the documentation, this project is meant for TinkerPop 2.x and Rexster. 根据文档,该项目适用于TinkerPop 2.x和Rexster。 I don't believe it works with TinkerPop 3.x and Gremlin Server which is what JanusGraph is based on.
我不认为它适用于JaninkGraph所基于的TinkerPop 3.x和Gremlin Server。 If you need a Python OGM of some sort for TinkerPop 3.x you might consider:
如果您需要TinkerPop 3.x的某种Python OGM,您可以考虑:
https://github.com/davebshow/goblin https://github.com/davebshow/goblin
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.