2013-08-28 31 views

Trả lời

4

Như bạn đã tìm thấy cho chính mình, bạn có thể sử dụng phương pháp Blueprints getIndexedKeys(Vertex.class) cho điều này, tuy nhiên hệ thống kiểu Titan có nhiều thứ để cung cấp hơn createKeyIndex. Các bạn còn làm việc với Titan bạn sẽ càng muốn tìm hiểu về hệ thống Loại Maker:

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

Trong trường hợp đó các loại trả về bởi getIndexedKeys có thể không đủ. Dưới đây là một số Gremlin để giúp bạn biết thêm chi tiết:

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] 

Bạn có thể muốn nhìn vào API Titan để biết thêm thông tin về TitanKey được trả về từ cuộc gọi mà để getVertices (như các loại được lưu trữ như đỉnh):

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

+0

Điều này thật tuyệt vời, cảm ơn @ stephen-mallette. Bạn nói đúng về các loại khác của Titan: Tôi đã khám phá tích hợp ElasticSearch với Titan để có các chỉ mục và tìm kiếm nâng cao hơn. – bcm360

5

Trong vỏ Gremlin, bạn có thể sử dụng Blueprints' KeyIndexableGraphgetIndexedKeys chức năng:

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

(my_key_1, my_key_2, và my_key_3 là 3 phím đỉnh được lập chỉ mục)

Để lấy các chỉ số cho các phím trên cạnh, sử dụng Edge.class thay cho số Vertex.class ở trên.

Các vấn đề liên quan