【发布时间】:2018-05-28 10:26:41
【问题描述】:
我正在使用 JanusGraph 0.2.0 版本。我的图表中有以下两个索引。
mgmt = graph.openManagement()
keyName = mgmt.getPropertyKey('propertyKeyA')
labelName = mgmt.getVertexLabel('labelA')
mgmt.buildIndex('labelA_keyAIndex', Vertex.class).addKey(keyName).indexOnly(labelName).buildCompositeIndex()
mgmt.commit()
mgmt.awaitGraphIndexStatus(graph, 'labelA_keyAIndex').call()
mgmt = graph.openManagement()
mgmt.updateIndex(mgmt.getGraphIndex("labelA_keyAIndex"), SchemaAction.REINDEX).get()
mgmt.commit()
mgmt.awaitGraphIndexStatus(graph, 'labelA_keyAIndex').status(SchemaStatus.ENABLED).call()
mgmt = graph.openManagement()
keyName = mgmt.getPropertyKey("propertyKeyB")
mgmt.buildIndex("keyBIndex",Vertex.class).addKey(keyName).buildCompositeIndex()
mgmt.commit()
mgmt.awaitGraphIndexStatus(graph, "keyBIndex").call();
mgmt = graph.openManagement()
mgmt.updateIndex(mgmt.getGraphIndex("keyBIndex"), SchemaAction.REINDEX).get()
mgmt.commit()
mgmt.awaitGraphIndexStatus(graph, 'keyBIndex').status(SchemaStatus.ENABLED).call()
g.V().hasLabel("labelA").has("propertyKeyB","value").has("propertyKeyA","value").valueMap()
1) 上述查询会使用两个索引还是只使用labelA_KeyAIndex?
我在图中使用 propertyKeyB 和许多其他标签,因此我为 propertyKeyB keyBIndex 创建了一个单独的索引,而没有指定 indexOnly(label)。
提前致谢
【问题讨论】:
-
我希望你不要在图中使用世界列,它很快就会变得非常混乱。也就是说,将 .profile() 附加到遍历的末尾以查看使用了哪些索引。在 JanusGraph 中,图索引仅用于随后的初始查找,以顶点为中心的索引接管。
标签: indexing gremlin janusgraph gremlin-server