titan警告:查询需要迭代所有顶点[(name< >null)]

toe95027  于 2021-06-09  发布在  Hbase
关注(0)|答案(1)|浏览(328)

我用了下面的代码

mgmt = g.getManagementSystem()
PropertyKey name = mgmt.makePropertyKey("name").dataType(String.class).make();
mgmt.buildIndex("name",Vertex.class).addKey(name).unique().buildCompositeIndex();

在从图表中检索数据时,我收到了这个警告,

TransactionalGraph tx = g.newTransaction();
Iterator vertex=tx.query().has("name").vertices.iterator();

遍历整个图以获取顶点,而不是索引顶点。请建议更改。

kwvwclae

kwvwclae1#

这里有一个指向Titan1.0索引文档的链接,但是它对复合索引的描述也适用于0.5.2。
复合索引非常快速有效,但仅限于对特定的、先前定义的属性键组合进行相等查找。
复合索引用于精确匹配键值检索。查询应该包含要查找的属性值,以便利用索引。

tx.query().has("name", "userRaj").vertices.iterator()

你在问题中的编码方式是,它必须扫描所有具有该属性的顶点 name 因为它不试图匹配任何特定的值(即。 null ).

WARN  com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx  - Query requires iterating over all vertices [(name <> null)]. For better performance, use indexes

如果您正在进行新的titan开发,我建议您升级到1.0,因为0.5.x流上不会有更多的版本。

相关问题