【问题标题】:Titan DB bad indexTitan DB 坏索引
【发布时间】:2015-10-01 08:08:54
【问题描述】:

我有这个 Titan 数据库架构:

val mgmt = getManagementSystem

val guid = mgmt.makePropertyKey("guid").dataType(classOf[String]).make()
mgmt.buildIndex("byGuid",classOf[Vertex]).addKey(guid).unique().buildCompositeIndex()
mgmt.commit()

mgmt.makePropertyKey("foo").dataType(classOf[String]).make()
mgmt.makePropertyKey("fo2").dataType(classOf[String]).make()
mgmt.makePropertyKey("about").dataType(classOf[String]).make()

/**
foo foo foo
*//

mgmt.commit()

当我尝试这样做时:

db.V.has("guid", guid).next()

然后在 Debug 中是这条消息:

[warn] c.t.t.g.t.StandardTitanTx - Query requires iterating over all vertices [()]. For better performance, use indexes

我使用了 Titan 文档,所有设置都像文档中一样。我不知道出了什么问题,请帮忙。谢谢。

【问题讨论】:

标签: scala indexing playframework titan


【解决方案1】:

您必须等待复合索引从INSTALLED 切换到ENABLED 状态。

为此,请将您的代码更改为如下所示

// Create an index
m = graph.openManagement()
m.buildIndex('names', Vertex.class).addKey(m.getPropertyKey('name')).buildCompositeIndex()
m.commit()
graph.tx().commit()

// Block until the SchemaStatus transitions from INSTALLED to REGISTERED
ManagementSystem.awaitGraphIndexStatus(graph, 'names').status(SchemaStatus.REGISTERED).call()

// Reindex using TitanManagement
m = graph.openManagement()
i = m.getGraphIndex('names')
m.updateIndex(i, SchemaAction.REINDEX)
m.commit()

// Enable the index
ManagementSystem.awaitGraphIndexStatus(graph, 'names').status(SchemaStatus.ENABLED).call()

欲了解更多信息,请查看here

【讨论】:

    猜你喜欢
    • 2017-03-27
    • 2014-10-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-16
    • 2012-10-29
    相关资源
    最近更新 更多