我正在尝试为顶点标签创建索引.Vertex创建如下
val v0 = graph + "A"
我的每个gremlin查询基于顶点标签 . 获取下面的警告消息
WARN c.t.t.g.transaction.StandardTitanTx - Query requires iterating over all vertices [(~label = 301)]. For better performance, use indexes
项目使用Titan cassandra(存储后端),下面是使用的SBT依赖项,
"com.michaelpollmeier" %% "gremlin-scala" % "3.0.2-incubating.2",
"com.thinkaurelius.titan" % "titan-core" % "1.0.0",
"com.thinkaurelius.titan" % "titan-cassandra" % "1.0.0",
"com.netflix.astyanax" % "astyanax-cassandra" % "3.9.0",
"com.netflix.astyanax" % "astyanax-core" % "3.9.0",
"com.netflix.astyanax" % "astyanax-thrift" % "3.9.0"
创建索引如下,
mgmt.makePropertyKey("endpoint").dataType(classOf[String]).make();
mgmt.buildIndex("endpoint",classOf[Vertex]).addKey(name1).unique().buildCompositeIndex()
mgmt.commit()
graph.tx().commit()
得到这个错误
com.thinkaurelius.titan.core.SchemaViolationException:为key [~T $ SchemaName]和value [rtendpoint]添加此属性违反了唯一性约束[SystemIndex#~T $ SchemaName]
1 回答
根据this:
所以我假设该过程应该与定义的过程相同here .
基于该假设,首先,您将索引应用于不属于标签的属性 . 但是,在高级加载数据时创建图形模式是个好主意 . 话虽这么说你可能想要做以下事情:
1. Define Your Vertex Labels
这可以通过以下方式完成:
2. Define your properties
这让Titan知道它可以索引哪些属性:
3. Define the Indexed Properties
索引属性时,对这些属性的遍历将更快: