use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.
the class IndexRecoveryIT method createIndexAndAwaitPopulation.
private void createIndexAndAwaitPopulation(Label label) {
IndexDefinition index = createIndex(label);
try (Transaction tx = db.beginTx()) {
db.schema().awaitIndexOnline(index, 10, SECONDS);
tx.success();
}
}
use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.
the class IndexRestartIT method createIndex.
private IndexDefinition createIndex() {
try (Transaction tx = db.beginTx()) {
IndexDefinition index = db.schema().indexFor(myLabel).on("number_of_bananas_owned").create();
tx.success();
return index;
}
}
use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.
the class IndexSamplingCancellationTest method indexOn.
private IndexDefinition indexOn(Label label, String propertyKey) {
IndexDefinition index;
try (Transaction tx = db.beginTx()) {
index = db.schema().indexFor(label).on(propertyKey).create();
tx.success();
}
return index;
}
use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.
the class IndexIT method shouldListConstraintIndexesInTheBeansAPI.
@Test
public void shouldListConstraintIndexesInTheBeansAPI() throws Exception {
// given
Statement statement = statementInNewTransaction(SecurityContext.AUTH_DISABLED);
statement.schemaWriteOperations().uniquePropertyConstraintCreate(SchemaDescriptorFactory.forLabel(statement.tokenWriteOperations().labelGetOrCreateForName("Label1"), statement.tokenWriteOperations().propertyKeyGetOrCreateForName("property1")));
commit();
// when
try (Transaction tx = db.beginTx()) {
Set<IndexDefinition> indexes;
IndexDefinition index;
indexes = Iterables.asSet(db.schema().getIndexes());
// then
assertEquals(1, indexes.size());
index = indexes.iterator().next();
assertEquals("Label1", index.getLabel().name());
assertEquals(asSet("property1"), Iterables.asSet(index.getPropertyKeys()));
assertTrue("index should be a constraint index", index.isConstraintIndex());
// when
try {
index.drop();
fail("expected exception");
}// then
catch (IllegalStateException e) {
assertEquals("Constraint indexes cannot be dropped directly, " + "instead drop the owning uniqueness constraint.", e.getMessage());
}
}
}
use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.
the class IndexStatisticsIT method indexAliensBySpecimen.
private IndexDefinition indexAliensBySpecimen() {
try (Transaction tx = db.beginTx()) {
IndexDefinition definition = db.schema().indexFor(ALIEN).on(SPECIMEN).create();
tx.success();
return definition;
}
}
Aggregations