use of org.neo4j.graphdb.schema.IndexCreator in project neo4j by neo4j.
the class Neo4jMatchers method createIndexNoWait.
public static IndexDefinition createIndexNoWait(GraphDatabaseService beansAPI, Label label, String... properties) {
IndexDefinition indexDef;
try (Transaction tx = beansAPI.beginTx()) {
IndexCreator indexCreator = beansAPI.schema().indexFor(label);
for (String property : properties) {
indexCreator = indexCreator.on(property);
}
indexDef = indexCreator.create();
tx.success();
}
return indexDef;
}
use of org.neo4j.graphdb.schema.IndexCreator in project neo4j by neo4j.
the class StringLengthIndexValidationIT method createIndex.
private long createIndex(String... keys) {
long indexId;
try (Transaction tx = db.beginTx()) {
IndexCreator indexCreator = tx.schema().indexFor(LABEL_ONE);
for (String key : keys) {
indexCreator = indexCreator.on(key);
}
var index = indexCreator.create();
indexId = getIndexIdFrom(index);
tx.commit();
}
try (Transaction tx = db.beginTx()) {
tx.schema().awaitIndexesOnline(2, MINUTES);
tx.commit();
}
return indexId;
}
use of org.neo4j.graphdb.schema.IndexCreator in project neo4j by neo4j.
the class SchemaAcceptanceTest method tokenIndexCreatorThrowsOnProperty.
@Test
void tokenIndexCreatorThrowsOnProperty() {
try (var tx = db.beginTx()) {
IndexCreator indexCreator = tx.schema().indexFor(AnyTokens.ANY_LABELS);
assertThatThrownBy(() -> indexCreator.on("property")).isInstanceOf(ConstraintViolationException.class).hasMessageContaining("LOOKUP indexes doesn't support inclusion of property keys.");
}
}
use of org.neo4j.graphdb.schema.IndexCreator in project neo4j by neo4j.
the class SchemaAcceptanceTest method tokenIndexCreatorThrowsOnUnsupportedIndexTypes.
@Test
void tokenIndexCreatorThrowsOnUnsupportedIndexTypes() {
try (var tx = db.beginTx()) {
IndexCreator indexCreator = tx.schema().indexFor(AnyTokens.ANY_LABELS);
assertThatThrownBy(() -> indexCreator.withIndexType(IndexType.BTREE)).isInstanceOf(ConstraintViolationException.class).hasMessageContaining("Only LOOKUP index type supported for token indexes.");
assertThatThrownBy(() -> indexCreator.withIndexType(IndexType.FULLTEXT)).isInstanceOf(ConstraintViolationException.class).hasMessageContaining("Only LOOKUP index type supported for token indexes.");
}
}
use of org.neo4j.graphdb.schema.IndexCreator in project neo4j by neo4j.
the class IndexProviderApprovalTest method createIndex.
private static void createIndex(GraphDatabaseService db, Label label, String... properties) {
IndexDefinition indexDef;
try (Transaction tx = db.beginTx()) {
IndexCreator indexCreator = tx.schema().indexFor(label);
for (String property : properties) {
indexCreator = indexCreator.on(property);
}
indexDef = indexCreator.create();
tx.commit();
}
try (Transaction tx = db.beginTx()) {
tx.schema().awaitIndexOnline(indexDef, 1, MINUTES);
}
}
Aggregations