2015-07-13 66 views
0

我有這樣的巨人DB模式:泰坦DB壞指數

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() 

然後在調試是這樣的消息:

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

我用泰坦文檔和所有文件中的設置。我不知道什麼是錯的,請幫助。謝謝。

+1

可能重複[泰坦警告:查詢需要循環訪問所有頂點( http://stackoverflow.com/questions/21725758/titan-warning-query-requires-iterating-over-all-vertices) – Peanut

回答

0

您必須等待複合索引從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