Titan图数据库:使用索引后端加速AND和OR gremlin查询

时间:2016-06-05 14:21:07

标签: solr cassandra titan gremlin

我在生产中使用了Titan 1.0。 (Cassandra + Solr)我想知道如何通过索引后端来加速和/或查询。假设已经在" user_info"上定义了混合索引。和" vertex_label"领域。如何告诉Titan使用索引后端作为以下查询或其他类似数据准备的数据准备来源:

g.V().or(__.has("user_info",Text.textRegex("job=Teacher")),
      __.has("vertext_label","user")))

我已使用query.force-index = true检查此查询,以查看它是否使用任何类型的索引;但抛出的异常显示它没有。

1 个答案:

答案 0 :(得分:3)

在Aurelius邮件列表上是answered,但由于SO更喜欢文字而不是链接,所以这里又是:

将其拆分为2个查询并合并结果:

result = g.V().has("user_info", Text.textRegex("job=Teacher")).toSet()
result.addAll(g.V().has("vertex_label", "user"))

或者使用中间遍历索引查找(需要TP 3.2):

g.V().has("user_info", Text.textRegex("job=Teacher")).aggregate("x").cap("x").
  V().has("vertex_label", "user").aggregate("x").cap("x")