2013-08-28 76 views

回答

4

正如你自己找到的,你可以使用Blueprints getIndexedKeys(Vertex.class)方法,但是泰坦类型系统比createKeyIndex提供更多提供。你与泰坦的工作时间越长,你就越想了解该类型设备系统:

https://github.com/thinkaurelius/titan/wiki/Type-Definition-Overview

在这种情况下,通过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] 

你可能想看看泰坦API用于对从该调用返回getVerticesTitanKey更多的信息(如类型存储为顶点):

http://thinkaurelius.github.io/titan/javadoc/0.3.2/com/thinkaurelius/titan/core/TitanKey.html

+0

这太好了,谢谢@ stephen-mallette。对于泰坦的其他类型你是对的:我已经在探索与Titan的ElasticSearch集成以进行更高级的索引和搜索。 – bcm360

5

在小鬼的外壳,你可以使用蓝图KeyIndexableGraphgetIndexedKeys功能:

gremlin> g.getIndexedKeys(Vertex.class) 
==>my_key_1 
==>my_key_2 
==>my_key_3 

my_key_1my_key_2my_key_3是3个索引顶点键)

要在抢索引键边缘,使用Edge.class代替上面的Vertex.class