Używam Titan v0.3.1 i chciałbym zobaczyć listę kluczy, które już zaindeksowałem poprzez createKeyIndex
. Jak mogę to zrobić?Jak mogę uzyskać listę indeksowanych kluczy w programie Titan?
Odpowiedz
Jak sam się przekonałeś, możesz użyć do tego metody Blueprints getIndexedKeys(Vertex.class)
, jednak system typu Titan ma znacznie więcej do zaoferowania niż createKeyIndex
. Im dłużej pracować z Tytana tym bardziej będzie chciał dowiedzieć się o systemie Maker Rodzaj:
https://github.com/thinkaurelius/titan/wiki/Type-Definition-Overview
W tym przypadku typy zwracane przez getIndexedKeys
może nie wystarczyć. Oto niektóre Gremlin, aby uzyskać więcej szczegółów:
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]
Możecie zajrzeć do API Titan, aby uzyskać więcej informacji na temat TitanKey
, który jest zwracany z tego zaproszenia do getVertices
(jak typy są przechowywane jako wierzchołków):
http://thinkaurelius.github.io/titan/javadoc/0.3.2/com/thinkaurelius/titan/core/TitanKey.html
W powłoce Gremlin, można użyć plany KeyIndexableGraphgetIndexedKeys
funkcję:
gremlin> g.getIndexedKeys(Vertex.class)
==>my_key_1
==>my_key_2
==>my_key_3
(my_key_1
, my_key_2
i my_key_3
są 3 indeksowanych klucze Vertex)
chwycić indeksów dla klawiszy na krawędzi, użyj Edge.class
zamiast powyższego Vertex.class
.
To świetnie, dzięki @ stephen-mallette. Masz rację co do innych typów Titana: już odkrywam integrację ElasticSearch z Tytanem, by uzyskać bardziej zaawansowane indeksy i wyszukiwanie. – bcm360