我用了下面的代码
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();
遍历整个图以获取顶点,而不是索引顶点。请建议更改。
1条答案
按热度按时间kwvwclae1#
这里有一个指向Titan1.0索引文档的链接,但是它对复合索引的描述也适用于0.5.2。
复合索引非常快速有效,但仅限于对特定的、先前定义的属性键组合进行相等查找。
复合索引用于精确匹配键值检索。查询应该包含要查找的属性值,以便利用索引。
你在问题中的编码方式是,它必须扫描所有具有该属性的顶点
name
因为它不试图匹配任何特定的值(即。null
).如果您正在进行新的titan开发,我建议您升级到1.0,因为0.5.x流上不会有更多的版本。