I have created an index on User and on uuid
if I do:
schema.vertexLabel("User").describe()
I get:
schema.vertexLabel("User").index("byUuid").materialized().by("uuid").add()
When I am running:
g.V().hasLabel("User").has("uuid","oneUuid")
The index is picked up properly..
but when I do the following:
g.V().or(__.hasLabel("User").has("uuid","oneUuid"), __.hasLabel("User").has("uuid","anotherUUID"))
I am getting:
org.apache.tinkerpop.gremlin.driver.exception.ResponseException: Could not find an index to answer query clause and graph.allow_scan is disabled:
Thanks!
or()
is not easily optimizable as you can do much more complicated things like:
g.V().or(
hasLabel("User").has("uuid","oneUuid"),
hasLabel("User").has("name","bob"))
...where one or more condition could not be answered by an index lookup. It is doable and will likely be done in future versions, but afaik none of the currently available graph databases is trying to optimize the OrStep
.
Anyway, your sample query can easily be rewritten so that it actually uses the index:
g.V().hasLabel("User").has("uuid", within("oneUuid", "anotherUUID"))