was*_*ren 2 indexing elasticsearch gremlin titan
在我们的大型Titan Graph数据库中,我注意到以下行为:
\,,,/
(o o)
-----oOOo-(_)-oOOo-----
14:16:35 WARN org.apache.hadoop.util.NativeCodeLoader - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
gremlin> g = TitanFactory.open('/home/willem/workspace/ovc/src/main/resources/titan-cassandra-es.properties')
14:16:44 WARN com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration - Local setting cache.db-cache-time=0 (Type: GLOBAL_OFFLINE) is overridden by globally managed value (180000). Use the ManagementSystem interface instead of the local configuration to control this setting.
==>titangraph[com.thinkaurelius.titan.diskstorage.cassandra.astyanax.AstyanaxStoreManager:[10.1.0.200]]
gremlin> g.indexQuery("mediaSerialNBStringIdx","v.mediaSerialNB:EB*").vertices().count()
==>937
gremlin> g.V().has("mediaSerialNB",PREFIX,"EB").count()
14:17:17 WARN com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx - Query requires iterating over all vertices [(mediaSerialNB PREFIX EB)]. For better performance, use indexes
Run Code Online (Sandbox Code Playgroud)
因此,使用indexQuery(...)直接寻址索引会利用索引,但将其留给查询优化器,它不会发现该特定字段上存在MixedIndex的事实.
这是使用elasticsearch 1.2.2运行的Titan 0.5.3.
这些是索引细节:
gremlin> m = g.getManagementSystem()
==>com.thinkaurelius.titan.graphdb.database.management.ManagementSystem@6a26cb53
gremlin> m.getGraphIndex("mediaSerialNBStringIdx").isMixedIndex()
==>true
gremlin> m.getGraphIndex("mediaSerialNBStringIdx").getFieldKeys()
==>mediaSerialNB
gremlin> m.getGraphIndex("mediaSerialNBStringIdx").getBackingIndex()
==>search
gremlin> k = m.getPropertyKey("mediaSerialNB")
==>mediaSerialNB
gremlin> m.getGraphIndex("mediaSerialNBStringIdx").getIndexStatus(k)
==>INSTALLED
Run Code Online (Sandbox Code Playgroud)
索引状态是"已安装"而不是"启用"这一事实能给我提供线索吗?如果是这样,我如何帮助elasticsearch启用它?
阅读重新索引,我发现了以下内容:
mgmt.updateIndex(rindex, SchemaAction.ENABLE_INDEX);
Run Code Online (Sandbox Code Playgroud)
但是我们的数据库告诉我们:
gremlin> mediaSerialNBKey = g.getPropertyKey("mediaSerialNB")
==>mediaSerialNB
gremlin> mediaSerialNBStringIdx = m.getGraphIndex("mediaSerialNBStringIdx")
==>com.thinkaurelius.titan.graphdb.database.management.TitanGraphIndexWrapper@7c54dcff
gremlin> mediaSerialNBStringIdx.getParametersFor(mediaSerialNBKey)
==>mapping->STRING
==>mapped-name->4h6t
==>status->INSTALLED
gremlin> m.updateIndex(mediaSerialNBStringIdx, SchemaAction.ENABLE_INDEX)
Update action [ENABLE_INDEX] does not apply to any fields for index [com.thinkaurelius.titan.graphdb.database.management.TitanGraphIndexWrapper@7c54dcff]
Run Code Online (Sandbox Code Playgroud)
小智 5
是的,您需要启用索引.要执行此操作,索引必须处于"已注册"状态,而不是"INSTALLED",因为它是您的情况.通常,当使用相同存储后端的所有titan实例确认索引更改时,此转换会自动发生.
有可能,你有一些不再活跃的实例.您可以在gremlin控制台中列出所有实例:
m=g.getManagementSystem()
m.getOpenInstances()
Run Code Online (Sandbox Code Playgroud)
如果有任何死实例,您应该使用手动删除它们
mgmt.forceCloseInstance("dead-instance-id")
mgmt.commit()
Run Code Online (Sandbox Code Playgroud)
您可以在文档中找到更多信息,第27.2节.
根据我的经验,最好在执行索引维护之前关闭除gremlin会话之外的所有实例.
现在,您可以手动注册索引(请参阅 第28.7.1节):
m = g.getManagementSystem()
mediaSerialNBStringIdx = m.getGraphIndex("mediaSerialNBStringIdx")
m.updateIndex(mediaSerialNBStringIdx, SchemaAction.REGISTER_INDEX)
m.commit()
Run Code Online (Sandbox Code Playgroud)
去检查:
m = g.getManagementSystem()
k = m.getPropertyKey("mediaSerialNB")
m.getGraphIndex("mediaSerialNBStringIdx").getIndexStatus(k)
// should return REGISTERED
Run Code Online (Sandbox Code Playgroud)
现在,您可以成功启用索引:
m = g.getManagementSystem()
mediaSerialNBStringIdx = m.getGraphIndex("mediaSerialNBStringIdx")
m.updateIndex(mediaSerialNBStringIdx, SchemaAction.ENABLE_INDEX)
m.commit()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
747 次 |
| 最近记录: |