1

我已經創建用戶和UUID的爲什麼或()查詢未在Datastax DSE 5.0.x Graph中使用索引?

的指數,如果我做的:

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是 已禁用:

謝謝!

回答

3

or()不容易優化的,你可以做更復雜的東西,如:

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

...其中一個或多個條件無法通過索引查找來回答。這是可行的,並可能在未來的版本中完成,但afaik目前可用的圖形數據庫都沒有試圖優化OrStep

總之,您的樣本查詢可以很容易地被改寫,使其實際使用該索引:

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

謝謝!我知道內部(),但我期待我的具體或()情況轉換爲您發送的。 –

相關問題