2014-09-06 6 views
11

경영 시스템을 살펴 보았지만 어떤 것들은 여전히 ​​나를 피합니다. 본질적으로 내가하고 싶은 것은 :Titan db 모든 그래프 인덱스를 나열하는 방법

  • (정점 중심 포함) 모든 에지 기반 인덱스를 나열하십시오.
  • 모든 정점 기반 색인을 나열하십시오 (색인이 레이블에 첨부 된 경우 레이블 단위 기준).

기본적으로 그래프 스키마를 매핑하는 것과 같습니다.

나는 몇 가지 시도를했지만 부분적으로 데이터를 얻는다.

g.getIndexdKeys(<Vertex or Edge>); 
//basic information. Doesn't seem to return any buildEdgeIndex() based indexes 

mgmt.getVertexLabels(); 
// gets labels, can't find a way of getting indexes attached to these labels. 

mgmt.getGraphIndexes(Vertex.class); 
// works nicely I can retrieve Vertex indexes and get pretty much any 
// information I want out of them except for information regarding 
// indexOnly(label). So I can't tell what label these indexes are attached to. 

mgmt.getGraphIndexes(Edge.class); 
// doesn't seem to return any buildEdgeIndex() indexes. 

빈칸을 채우는 데 도움이 될 것입니다.

이드 알고 싶다 :

  • 가 어떻게 indexOnly를 통해 (인덱스에 부착 또는 라벨) 라벨()
  • 가 어떻게 buildEdgeIndex를 통해 설정 가장자리 인덱스를 나열 할에 부착 된 인덱스를 찾을 수 있습니다()와 해당 가장자리 레이블?

미리 감사드립니다.

추가 정보 : 타이탄 0.5.0, 카산드라 백엔드, rexster를 통해.

답변

9

정말 간단하지 않으므로 예제를 사용하여 보여 드리겠습니다.

의는 하나님의 그래프 + 신 이름에 대한 추가 인덱스부터 시작하자 :

g = TitanFactory.open("conf/titan-cassandra-es.properties") 
GraphOfTheGodsFactory.load(g) 
m = g.getManagementSystem() 
name = m.getPropertyKey("name") 
god = m.getVertexLabel("god") 
m.buildIndex("god-name", Vertex.class).addKey(name).unique().indexOnly(god).buildCompositeIndex() 
m.commit() 

이제 다시 인덱스 정보를 꺼내 보자.

gremlin> m = g.getManagementSystem() 
==>com.t[email protected]2f414e82 

gremlin> // get the index by its name 
gremlin> index = m.getGraphIndex("god-name") 
==>com.thinkau[email protected]e4f5395 

gremlin> // determine which properties are covered by this index 
gremlin> gn.getFieldKeys() 
==>name 

// 
// the following part shows what you're looking for 
// 
gremlin> import static com.thinkaurelius.titan.graphdb.types.TypeDefinitionCategory.* 

gremlin> // get the schema vertex for the index 
gremlin> sv = m.getSchemaVertex(index) 
==>god-name 

gremlin> // get index constraints 
gremlin> rel = sv.getRelated(INDEX_SCHEMA_CONSTRAINT, Direction.OUT) 
==>[email protected] 

gremlin> // get the first constraint; no need to do a .hasNext() check in this 
gremlin> // example, since we know that we will only get a single entry 
gremlin> sse = rel.iterator().next() 
==>[email protected] 

gremlin> // finally get the schema type (that's the vertex label that's used in .indexOnly()) 
gremlin> sse.getSchemaType() 
==>god 

건배, 다니엘

+0

놀라운 감사합니다! 이미 그 중 일부를 알았지 만 정점 레이블을 얻지 못했습니다. –