【问题标题】:Why or() queries are not using index in Datastax DSE 5.0.x Graph?为什么 or() 查询不使用 Datastax DSE 5.0.x Graph 中的索引?
【发布时间】:2017-08-29 10:36:27
【问题描述】:

我在用户和 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 是 禁用:

谢谢!

【问题讨论】:

    标签: datastax datastax-enterprise gremlin datastax-enterprise-graph


    【解决方案1】:

    or() 不容易优化,因为您可以做更复杂的事情,例如:

    g.V().or(
        hasLabel("User").has("uuid","oneUuid"),  
        hasLabel("User").has("name","bob"))
    

    ...索引查找无法回答一个或多个条件。这是可行的,并且可能会在未来的版本中完成,但是目前可用的图形数据库都没有尝试优化 OrStep

    无论如何,您的示例查询可以很容易地重写,以便它实际使用索引:

    g.V().hasLabel("User").has("uuid", within("oneUuid", "anotherUUID"))
    

    【讨论】:

    • 谢谢!我知道 inside() 但我希望我的特定 or() 案例转换为您发送的案例..
    猜你喜欢
    • 2017-05-05
    • 2017-05-05
    • 2020-12-20
    • 2023-03-28
    • 2017-05-05
    • 1970-01-01
    • 1970-01-01
    • 2014-05-11
    • 1970-01-01
    相关资源
    最近更新 更多