use of org.neo4j.graphdb.schema.IndexDefinition 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);
}
}
use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.
the class AppsIT method canListIndexes.
@Test
public void canListIndexes() throws Exception {
// GIVEN
Label label = label("Person");
beginTx();
IndexDefinition index = db.schema().indexFor(label).on("name").create();
finishTx();
waitForIndex(db, index);
// WHEN / THEN
executeCommand("schema ls", ":Person", IndexState.ONLINE.name());
}
use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.
the class AppsIT method failSamplingWhenProvidingBadProperty.
@Test
public void failSamplingWhenProvidingBadProperty() throws Exception {
// GIVEN
Label label = label("Person");
String property = "name";
beginTx();
IndexDefinition index = db.schema().indexFor(label).on(property).create();
finishTx();
waitForIndex(db, index);
// WHEN / THEN
try {
executeCommand("schema sample -l Person -p namn");
fail("This should fail");
} catch (ShellException e) {
assertThat(e.getMessage(), containsString("No property associated with 'namn' was found"));
}
}
use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.
the class AppsIT method canSampleAllIndexes.
@Test
public void canSampleAllIndexes() throws Exception {
// GIVEN
Label label = label("Person");
String property = "name";
beginTx();
IndexDefinition index = db.schema().indexFor(label).on(property).create();
finishTx();
waitForIndex(db, index);
// WHEN / THEN
executeCommand("schema sample -a");
}
use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.
the class AppsIT method failSampleWhenNoOptionGiven.
@Test
public void failSampleWhenNoOptionGiven() throws Exception {
// GIVEN
Label label = label("Person");
String property = "name";
beginTx();
IndexDefinition index = db.schema().indexFor(label).on(property).create();
finishTx();
waitForIndex(db, index);
// WHEN / THEN
try {
executeCommand("schema sample");
fail("This should fail");
} catch (ShellException e) {
assertThat(e.getMessage(), containsString("Invalid usage of sample"));
}
}
Aggregations