Search in sources :

Example 1 with IndexState

use of org.neo4j.graphdb.schema.Schema.IndexState in project neo4j by neo4j.

the class Schema method reportNodeIndexes.

private void reportNodeIndexes(Output out, org.neo4j.graphdb.schema.Schema schema, Label[] labels, String property, boolean verbose) throws RemoteException {
    ColumnPrinter printer = new ColumnPrinter(indent("ON "), "", "");
    Iterable<IndexDefinition> indexes = indexesByLabelAndProperty(schema, labels, property);
    int i = 0;
    for (IndexDefinition index : sort(indexes, LABEL_COMPARE_FUNCTION)) {
        if (i == 0) {
            out.println("Indexes");
        }
        String labelAndProperties = String.format(":%s(%s)", index.getLabel().name(), commaSeparate(index.getPropertyKeys()));
        IndexState state = schema.getIndexState(index);
        String uniqueOrNot = index.isConstraintIndex() ? "(for uniqueness constraint)" : "";
        printer.add(labelAndProperties, state, uniqueOrNot);
        if (verbose && state == IndexState.FAILED) {
            printer.addRaw(schema.getIndexFailure(index));
        }
        i++;
    }
    if (i == 0) {
        out.println("No indexes");
    } else {
        printer.print(out);
    }
}
Also used : IndexDefinition(org.neo4j.graphdb.schema.IndexDefinition) ColumnPrinter(org.neo4j.shell.ColumnPrinter) IndexState(org.neo4j.graphdb.schema.Schema.IndexState)

Aggregations

IndexDefinition (org.neo4j.graphdb.schema.IndexDefinition)1 IndexState (org.neo4j.graphdb.schema.Schema.IndexState)1 ColumnPrinter (org.neo4j.shell.ColumnPrinter)1