I wasn't able to find how to list existing indexes (or indices) in the docs.
The command is currently mgmt.getGraphIndexes(Vertex.class) although I'm not sure if vertex-centric would show up under mgmt.getGraphIndexes(Edge.class) instead.
In addition to documentation I think it would be great if we created a getGraphIndexes() method that took no parameters and gave a list of all the indexes and their current state.
I'll point out the wiki page on indexing. It would make sense to pull a lot of that into the main documentation.
Adding @robertdale 's schema describe script more formally into the Gremlin Console could be interesting too, but I'd put that in a separate issue.
The idea for a generic getGraphIndexes() sounds interesting, but from a Java interface perspective, it would be more difficult.
There is no getIndexStatus() method on the base interface Index interface, and the signature is different between JanusGraphIndex.getIndexStatus(PropertyKey) and RelationTypeIndex.getIndexStatus().
Thanks for the link to @robertdale 's schema describe script. My real goal was easier to use administrative commands to gather schema information. I just started on a getGraphSchema() method for the management API using schema describe as a reference.
Also you're 100% correct about the other approaches being more work so I'm ultimately taking the path of least resistance 馃挴
I still need to add tests and do some work to make each section formatted correctly when separately called, but I finished a first pass. Right now I'm working with a width of 100 characters. I'd really like to get it to 80, but it's a bit of a challenge. If anyone has a really strong feeling about it I can shrink the first column from 30 to 15 and abbreviate some headers to get the other 5.
gremlin> mgmt.printGraphSchema()
==>------------------------------------------------------------------------------------------------
Vertex Label Name | Partitioned | Static |
---------------------------------------------------------------------------------------------------
titan | false | false |
location | false | false |
god | false | false |
demigod | false | false |
human | false | false |
monster | false | false |
---------------------------------------------------------------------------------------------------
Edge Label Name | Directed | Unidirected | Multiplicity |
---------------------------------------------------------------------------------------------------
brother | true | false | MULTI |
father | true | false | MANY2ONE |
mother | true | false | MANY2ONE |
battled | true | false | MULTI |
lives | true | false | MULTI |
pet | true | false | MULTI |
---------------------------------------------------------------------------------------------------
Property Key Name | Cardinality | Data Type |
---------------------------------------------------------------------------------------------------
name | SINGLE | class java.lang.String |
age | SINGLE | class java.lang.Integer |
time | SINGLE | class java.lang.Integer |
reason | SINGLE | class java.lang.String |
place | SINGLE | class org.janusgraph.core.attribute.Geoshape |
---------------------------------------------------------------------------------------------------
Vertex Index Name | Type | Unique | Backing | Key: Status |
---------------------------------------------------------------------------------------------------
name | Composite | true | internalindex | name: ENABLED |
vertices | Mixed | false | search | age: ENABLED |
---------------------------------------------------------------------------------------------------
Edge Index (VCI) Name | Type | Unique | Backing | Key: Status |
---------------------------------------------------------------------------------------------------
edges | Mixed | false | search | reason: ENABLED |
| | | | place: ENABLED |
---------------------------------------------------------------------------------------------------
Relation Index | Type | Direction | Sort Key | Order | Status |
---------------------------------------------------------------------------------------------------
battlesByTime | battled | BOTH | time | decr | ENABLED |
---------------------------------------------------------------------------------------------------
That looks really great, @chupman. Would it be possible to also include the schema constraints in this output?
@FlorianHockmann I'm targeted at 0.2.3 right now, but already planning to add it once it's merged to master.
printSchema has been merged to master, still need to add schema constraints section in master though.
as requested by "hadoopmarc" I am adding the following comments for consideration:
Global indexes (Composite,Mixed) can be limited to the "constraint" by indexOnly() step, from JanusGraph documentation:
mgmt.buildIndex('byNameAndLabel', Vertex.class).addKey(name).indexOnly(god).buildCompositeIndex()
We should also learn how the index was created from JanusGraphIndex instance, but the method to get IndexOnly() is not there, ...how to know it was limited to just "god" labels. I guess knowledge is there, because JG should is able to "reindex" just by the "name" of the index, repeating creation method entirely.
Regards, CM
BO XUAN LIFeb said: "You can do this:
JanusGraphSchemaType constraint = ManagementSystem.getGraphIndexDirect("indexName", ((ManagementSystem) mgmt).getWrappedTx()).getSchemaTypeConstraint();
and that works, could be wrapped in some kind of JanusGraphIndex method, like getIndexedOnlyBy()
Most helpful comment
I still need to add tests and do some work to make each section formatted correctly when separately called, but I finished a first pass. Right now I'm working with a width of 100 characters. I'd really like to get it to 80, but it's a bit of a challenge. If anyone has a really strong feeling about it I can shrink the first column from 30 to 15 and abbreviate some headers to get the other 5.