Gremlin Python createIndex(Tinkerpop) [英] Gremlin Python createIndex (Tinkerpop)

查看:123
本文介绍了Gremlin Python createIndex(Tinkerpop)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在将Tinkerpop与 gremlin python客户端一起使用默认 TinkerGraph-Gremlin (正在内存中运行).我想提高查询的性能并阅读 createIndex()函数,这听起来很适合我的用例,但不幸的是,我无法使用python客户端创建索引.我还尝试将这些行添加到启动groovy脚本中(通过groovy scirpt运行,没有错误),但是当我运行性能基准测试时,会得到相同的结果.

I'm currently using Tinkerpop with the gremlin python client with the default TinkerGraph-Gremlin(which is running in-memory). I wanted to boost the performance of my queries and read about the createIndex() function which sounds like the perfect it for my use case, sadly I wasn't able to create an index with the python client. I also tried to add these lines into the start-up groovy script (run through the groovy scirpt without errors) but when I run my performance benchmarks I get the same results.

所以我的问题是:我可以使用python客户端创建索引吗?如果没有,那是一种解决方法?还有一种方法可以询问gremlin是否定义了任何索引?

So my question is: Can I create an index with the python client and if not what would be a workaround? Also is there a way to ask gremlin if there are any indices defined?

PS .:对于groovy脚本,我使用了默认的 empty-sample.grooy ,并在最后一次调用之前添加了以下几行:

PS.: For the groovy script I used the default empty-sample.grooy and add these lines before the last call:

graph.createIndex("name", Vertex.class)
graph.createIndex("nap", Edge.class)

谢谢!

推荐答案

Python客户端将没有 createIndex()方法,因为TinkerPop不提供3.x索引的任何抽象.我们依赖于基础图数据库的索引和架构创建方法.您必须下降到该API级别并退出TinkerPop.

The python client won't have a createIndex() method as TinkerPop does not provide any abstractions over indices in 3.x. We rely on the index and schema creation methods of the underlying graph database. You have to drop down to that API level and out of TinkerPop.

如果仅确定是否使用查询速度创建索引,请记住,图形中只有8800个顶点,而TinkerGraph是内存中图.很少有几个顶点,您可能看不到速度上的明显区别.如果您想知道是否创建了索引,只需查询一下即可:

If you're only determining whether or not indices are created using the speed of your query keep in mind that your graph only has 8800 vertices in it and TinkerGraph is an in-memory graph. You might not see a massively discernible difference in speed with that few a number of vertices. If you want to know if your index is created just look it up:

gremlin> graph = TinkerGraph.open()
==>tinkergraph[vertices:0 edges:0]
gremlin> g = graph.traversal()
==>graphtraversalsource[tinkergraph[vertices:0 edges:0], standard]
gremlin> graph.createIndex('name',Vertex.class)
gremlin> graph.getIndexedKeys(Vertex.class)
==>name

这篇关于Gremlin Python createIndex(Tinkerpop)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆