我在User和on uuid上创建了一个索引
如果我这样做:
schema.vertexLabel("User").describe()
我明白了:
schema.vertexLabel("User").index("byUuid").materialized().by("uuid").add()
当我跑步时:
g.V().hasLabel("User").has("uuid","oneUuid")
正确拾取索引..
但是当我执行以下操作时:
g.V().or(__.hasLabel("User").has("uuid","oneUuid"), __.hasLabel("User").has("uuid","anotherUUID"))
我得到了:
org.apache.tinkerpop.gremlin.driver.exception.ResponseException:可以 找不到回答查询子句和graph.allow_scan的索引 禁用:
谢谢!
答案 0 :(得分:3)
or()
不容易优化,因为您可以执行更复杂的操作,例如:
g.V().or(
hasLabel("User").has("uuid","oneUuid"),
hasLabel("User").has("name","bob"))
...索引查找无法回答一个或多个条件。它是可行的,可能会在未来的版本中完成,但是当前可用的图形数据库都没有尝试优化OrStep
。
无论如何,您可以轻松地重写示例查询,以便它实际使用索引:
g.V().hasLabel("User").has("uuid", within("oneUuid", "anotherUUID"))