Gremlin 如何在Titan中获取索引键列表?

Gremlin 如何在Titan中获取索引键列表?,gremlin,titan,Gremlin,Titan,我使用的是Titan v0.3.1,希望看到我已经通过createKeyIndex索引的键的列表。我如何才能做到这一点?在Gremlin shell中,您可以使用Blueprints的getIndexeKeys函数: gremlin> g.getIndexedKeys(Vertex.class) ==>my_key_1 ==>my_key_2 ==>my_key_3 (my_key_1、my_key_2和my_key_3是3个索引顶点键) 要获取边上关键点的索引,请使用

我使用的是Titan v0.3.1,希望看到我已经通过
createKeyIndex
索引的键的列表。我如何才能做到这一点?

在Gremlin shell中,您可以使用Blueprints的
getIndexeKeys
函数:

gremlin> g.getIndexedKeys(Vertex.class)
==>my_key_1
==>my_key_2
==>my_key_3
my_key_1
my_key_2
my_key_3
是3个索引顶点键)


要获取边上关键点的索引,请使用
Edge.class
代替上面的
Vertex.class

正如您自己发现的,您可以使用Blueprints
getIndexedKeys(Vertex.class)
方法进行此操作,但是Titan类型的系统提供的功能远不止
createKeyIndex
。与Titan合作的时间越长,您就越想了解TypeMaker系统:

在这种情况下,
getIndexedKeys
返回的类型可能不够。下面是一些小精灵,让您了解更多细节:

gremlin> g = GraphOfTheGodsFactory.create('/tmp/titan')
13/08/28 16:28:23 INFO diskstorage.Backend: Configuring index [search] based on: 
...
13/08/28 16:28:25 INFO cluster.metadata: [Astaroth / Asteroth] [titan] update_mapping [vertex] (dynamic)
==>titangraph[local:/tmp/titan]
gremlin> import static com.thinkaurelius.titan.graphdb.types.system.SystemKey.*
==>import com.tinkerpop.gremlin.*
==>import com.tinkerpop.gremlin.java.*
==>import com.tinkerpop.gremlin.pipes.*
==>import com.tinkerpop.gremlin.pipes.filter.*
==>import com.tinkerpop.gremlin.pipes.sideeffect.*
==>import com.tinkerpop.gremlin.pipes.transform.*
...
==>import static com.thinkaurelius.titan.graphdb.types.system.SystemKey.*
gremlin> import com.thinkaurelius.titan.graphdb.types.*
==>import com.tinkerpop.gremlin.*
==>import com.tinkerpop.gremlin.java.*
==>import com.tinkerpop.gremlin.pipes.*
==>import com.tinkerpop.gremlin.pipes.filter.*
==>import com.tinkerpop.gremlin.pipes.sideeffect.*
==>import com.tinkerpop.gremlin.pipes.transform.*
...
==>import com.thinkaurelius.titan.graphdb.types.*
gremlin> g.newTransaction().getVertices(TypeClass, TitanTypeClass.KEY).collect{[it.name,it.dataType]}
==>[reason, class java.lang.String]
==>[name, class java.lang.String]
==>[type, class java.lang.String]
==>[time, class java.lang.Integer]
==>[place, class com.thinkaurelius.titan.core.attribute.Geoshape]
==>[age, class java.lang.Integer]
您可能希望查看Titan API,以获取有关调用
getVertices
返回的
TitanKey
的更多信息(因为类型存储为顶点):


太好了,谢谢@stephen mallette。关于Titan的其他类型,你是对的:我已经在探索ElasticSearch与Titan的集成,以获得更高级的索引和搜索。