从 gremlin-python 进行直接 gremlin 查询

Making direct gremlin queries from gremlin-python

我在 gremlin-python 中遇到了几个问题,而在纯 gremlin 中则不是这样:

因此,从 Python/gremlin-python 开始,我希望能够对服务器进行纯 gremlin 查询,并将其结果直接存储在 Python 变量中。这可能吗?

(如果重要的话,我在 Apache Zeppelin 上使用 gremlin-python)

I can't directly select a given vertex type (g.V('customer')) without iterating over all vertices (g.V().hasLabel('customer'))

g.V('customer') 在 Gremlin 中的意思是 "find a vertex with the id 'customer'" 而不是“查找带有标签 'customer' 的顶点。对于后者,你需要你写的 g.V().hasLabel('customer')。这些规则在Gremlin 的每个变体,包括 Python。而且,你是对的,像 g.V().hasLabel('customer') 这样的查询会很昂贵,因为没有多少图可以优化这种类型的操作。在大图上,通常会考虑这种情况您将使用 Gremlin Spark 执行的 OLAP 查询。

I get "Maximum Recursion reached" errors from Python. The same query in gremlin works smooth and fast

那是 bug. It is resolved now, but the fix is not released to pypi. A release is currently being prepared and so you will see this on 3.2.10 and 3.3.4. If you need an immediate patch, you can see that the fix was fairly trivial

The ".next()" command works really slow in gremlin-python while in gremlin takes 1 sec

我不确定你到底看到了什么。我认为您可能想要详细说明您的环境,以及如何重现差异的细节。也许您应该将这个问题提交给 gremlin-users 邮件列表。

So, from Python/gremlin-python, I would like to be able to make a pure gremlin query to the server and directly store its result in a Python variable. Is that possible?

这是完全可能的,并且正是 gremlin-python 的目的。它使您能够在 Python 中编写 Gremlin 并从服务器返回结果以根据需要在客户端进行处理。