Подтвердить что ты не робот

Titan db как перечислять все индексы графа

Я смотрел на систему управления, но некоторые вещи все еще ускользают от меня. По сути, я хочу сделать следующее:

  • Список всех индексов на основе Edge (включая центрированные по вершинам).
  • Список всех индексов, основанных на вершинах (на основе каждой метки, если индекс прикреплен к метке).

В основном это похоже на отображение схемы графа.

Я пробовал несколько вещей, но в лучшем случае получаю только частичные данные.

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() и их соответствующие метки метки?

Спасибо заранее.

Дополнительная информация: Titan 0.5.0, бэкэнд Cassandra, через rexster.

4b9b3361

Ответ 1

это не очень прямо, поэтому я покажу его с помощью примера.

Начнем с графика богов + дополнительного индекса для имен богов:

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 the vertex label that used in .indexOnly())
gremlin> sse.getSchemaType()
==>god

Cheers, Daniel