TitanDB不使用索引进行查询 [英] TitanDB not using indexes for query

查看:308
本文介绍了TitanDB不使用索引进行查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在两个属性上创建了索引:

I have created indexes on two properties:

mgmt.buildIndex("userId", Vertex.class).addKey(mgmt.makePropertyKey("userId").dataType(Integer.class).make()).buildCompositeIndex();

mgmt.buildIndex("firstNameIndex", Vertex.class).addKey(mgmt.makePropertyKey("firstName").dataType(String.class).make()).buildCompositeIndex();

在Gremlin shell上我可以看到索引已经创建:

On Gremlin shell i can see the indexes have been created:

g.getIndexedKeys(Vertex.class)
==>userId
==>firstName

现在当我这样查询最简单的顶点时:

Now when i so query on vertices like simplest one:

gremlin> g.V()
18:33:42 WARN  com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx  - Query requires iterating over all vertices [()]. For better performance, use indexes
==>v[512]
==>v[256]

或某些复杂的:

gremlin> g.V.has('firstName' ,CONTAINS,'Raj')
18:36:00 WARN  com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx  - Query requires iterating over all vertices [(firstName CONTAINS Raj)]. For better performance, use indexes
==>v[512]

为什么不使用索引进行查询。??

Why its not using indexes for query.??

创建索引和键索引之间有什么区别吗?
任何解释都会有所帮助。

And is there any difference between creation of indexes and key indexes.? Any Explanation will be helpful.

谢谢

推荐答案

基于 http://s3.thinkaurelius.com/ docs / titan / 1.0.0 / indexes.html#index-mixed


使用复合索引进行精确匹配索引检索。复合
索引不需要配置或操作外部索引
系统,并且通常比混合索引快得多。

Use a composite index for exact match index retrievals. Composite indexes do not require configuring or operating an external index system and are often significantly faster than mixed indexes.

作为例外,使用当查询约束的不同值的数字
相对较小或者预期一个
值与图形中的许多元素相关联时(即如果为低),精确匹配的混合索引选择性)。使用混合索引进行数字
范围,全文或地理空间索引。此外,使用混合索引
可以加快order()。by()查询。

As an exception, use a mixed index for exact matches when the number of distinct values for query constraint is relatively small or if one value is expected to be associated with many elements in the graph (i.e. in case of low selectivity). Use a mixed indexes for numeric range, full-text or geo-spatial indexing. Also, using a mixed index can speed up the order().by() queries.

在你的情况下您似乎正在进行全文搜索,您需要使用混合索引,因为复合索引仅用于完全匹配。

In your case that it seems you are doing a full text search you need to use a mixed index, since composite ones are only used for exact matches.

您可以在以下网址找到有关全文搜索索引的更多信息: http://s3.thinkaurelius.com/docs/titan/1.0.0/index-parameters.html#_full_text_search

You can find more info about full text search indices in: http://s3.thinkaurelius.com/docs/titan/1.0.0/index-parameters.html#_full_text_search

我没有看到指数和关键指数之间存在任何差异。以顶点为中心的索引与属性/关键索引不同。看看我提供的链接。希望这有帮助!

I don't see anywhere any difference between indices and key indices. Vertex-centric indices are different than property/key indices. Have a look at the link I provided. Hope this helps!

这篇关于TitanDB不使用索引进行查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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