Reputation: 1437
I am using Titan v0.3.1 and would like to see a list of which keys I have already indexed via createKeyIndex
. How can I do this?
Upvotes: 5
Views: 3000
Reputation: 46216
As you found for yourself you can use the Blueprints getIndexedKeys(Vertex.class)
method for this, however the Titan type system has a lot more to offer than createKeyIndex
. The longer you work with Titan the more you will want to learn about the Type Maker system:
https://github.com/thinkaurelius/titan/wiki/Type-Definition-Overview
In that case the types returned by getIndexedKeys
may not be enough. Here's some Gremlin to get you more details:
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]
You might want to look at the Titan API for more information on the TitanKey
that is returned from that call to getVertices
(as types are stored as vertices):
http://thinkaurelius.github.io/titan/javadoc/0.3.2/com/thinkaurelius/titan/core/TitanKey.html
Upvotes: 4
Reputation: 1437
In the Gremlin shell, you can use Blueprints' KeyIndexableGraph getIndexedKeys
function:
gremlin> g.getIndexedKeys(Vertex.class)
==>my_key_1
==>my_key_2
==>my_key_3
(my_key_1
, my_key_2
, and my_key_3
are the 3 indexed vertex keys)
To grab the indexes for keys on edges, use Edge.class
in place of Vertex.class
above.
Upvotes: 5