JanusGraphIndex how to retrieve constraint (indexOnly) specified for the global index?
Global indexes can be limited to the "constraint" by indexOnly() step, from JanusGraph documentation: mgmt.buildIndex('byNameAndLabel', Vertex.class).addKey(name).indexOnly(god).buildCompositeIndex() It is handled by the "createCompositeIndex(...) java code by: addSchemaEdge(indexVertex, (JanusGraphSchemaVertex) constraint, TypeDefinitionCategory.INDEX_SCHEMA_CONSTRAINT, null);
I should learn how the index was created from JanusGraphIndex instance, but the method is not there,... I need to have it automatically detected by the software somehow. Is any other way to know it was Indexed Only By the "god"?
|
|
hadoopmarc@...
Confirmed, could not find it either. Could you please add it as a comment to:
https://github.com/JanusGraph/janusgraph/issues/1163 Unless someone comes up with a solution, it seems you will have to keep track of label constraints yourself. Best wishes, Marc |
|
Thank you, Index class is having tx() transaction description, but I have not found it there as well, I have added these comments to 1163 as suggested. Regards, CM |
|
hadoopmarc@...
Thanks. Still, my earlier answer remains unsatisfactory. Somehow, a new JanusGraph instance must be able to load an existing schema from the system table and have the information about label constraints available. Otherwise, the instance would not be able to index newly added vertices and edges correctly.
Best wishes, Marc |
|
Boxuan Li
You can do this:
toggle quoted message
Show quoted text
JanusGraphSchemaType constraint = ManagementSystem.getGraphIndexDirect("indexName", ((ManagementSystem) mgmt).getWrappedTx()).getSchemaTypeConstraint(); If (constraint == null) then there is no constraint. Otherwise constraint.name() returns your indexOnly label. Best regards, Boxuan
|
|
Works like a charm, thank you Bo Xuan Li.
|
|