【问题标题】:Titan - strange behaviour of has() with mixed indexTitan - 具有混合索引的 has() 的奇怪行为
【发布时间】:2016-09-08 03:40:51
【问题描述】:

我有一个带有 ES 后端和用于持久性的 DynamoDB 的 Titan 图。

方法has("mykey", "value") 从不检索顶点。在查询由 Elasticsearch 索引的 mykey 时,它总是不返回任何内容。索引已更新并启用。

当运行这个查询时,

gremlin>  graph.indexQuery("verticesIndex2", "v.mykey:myvalue").vertices().asList().size()
==>1  // It works here!! The vertex is retrieved successfully.
gremlin> g.V().has("mykey", "myvalue").hasNext()
==>false // doesn't retrieve anything!!!
gremlin> g.V(16998408).values("mykey")
==>myvalue // the vertex exists in my graph for sure !!

我尝试了一个技巧来让它工作

gremlin> g.V().has("mykey").has("mykey", "myvalue").next() 
19:49:44 WARN  com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx  - Query requires iterating over all vertices [()]. For better performance, use indexes
==>v[16998408] // It works !!

这似乎是某个地方的问题,但不确定具体在哪里。对此有什么想法吗?

【问题讨论】:

    标签: amazon-dynamodb titan gremlin tinkerpop3


    【解决方案1】:

    我遇到了与 lucene 索引类似的问题 - 包括相同的索引使用症状。

    请注意,在不检索任何内容的查询中,它也不会抱怨缺少索引。但在查询中,它抱怨必须遍历所有顶点。

    我怀疑是索引失败了——简单的 has("...") 操作首先需要非索引搜索,所以成功,但每次使用索引搜索时,都会失败。

    【讨论】:

      【解决方案2】:

      我正在使用 ES 和 HBase,我也有同样的问题。

      当我使用 ES 为 String 类型构建混合索引时,当使用类似的东西进行查询时

      g.V().has("mykey", "myvalue").hasNext()
      

      它警告我我没有使用索引,而且查询速度很慢。

      但是当我使用 ES 为 Integer 类型构建混合索引并像这样查询时

      g.V().has("myInt", "myIntValue").hasNext()
      

      它不会发出任何警告,而且查询速度相当快。

      所以现在我对字符串类型使用复合索引来避免这种情况

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-07-12
        • 1970-01-01
        • 1970-01-01
        • 2015-06-25
        • 1970-01-01
        • 2016-10-20
        • 1970-01-01
        相关资源
        最近更新 更多