Ответ 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