use of org.neo4j.graphdb.schema.IndexCreator in project neo4j by neo4j.
the class FulltextProcedures method createRelationshipFulltextIndex.
@Deprecated(since = "4.3.0", forRemoval = true)
@Description("Create a relationship full-text index for the given relationship types and properties. " + "The optional 'config' map parameter can be used to supply settings to the index. " + "Supported settings are '" + PROCEDURE_ANALYZER + "', for specifying what analyzer to use " + "when indexing and querying. Use the `db.index.fulltext.listAvailableAnalyzers` procedure to see what options are available. " + "And '" + PROCEDURE_EVENTUALLY_CONSISTENT + "' which can be set to 'true' to make this index eventually consistent, " + "such that updates from committing transactions are applied in a background thread.")
@Procedure(name = "db.index.fulltext.createRelationshipIndex", mode = SCHEMA, deprecatedBy = "CREATE FULLTEXT INDEX command")
public void createRelationshipFulltextIndex(@Name("indexName") String name, @Name("relationshipTypes") List<String> relTypes, @Name("properties") List<String> properties, @Name(value = "config", defaultValue = "{}") Map<String, String> config) {
RelationshipType[] types = relTypes.stream().map(RelationshipType::withName).toArray(RelationshipType[]::new);
IndexCreator indexCreator = transaction.schema().indexFor(types);
createIndex(indexCreator, name, properties, config);
}
use of org.neo4j.graphdb.schema.IndexCreator in project neo4j by neo4j.
the class FulltextProcedures method createNodeFulltextIndex.
@Deprecated(since = "4.3.0", forRemoval = true)
@Description("Create a node full-text index for the given labels and properties. " + "The optional 'config' map parameter can be used to supply settings to the index. " + "Supported settings are '" + PROCEDURE_ANALYZER + "', for specifying what analyzer to use " + "when indexing and querying. Use the `db.index.fulltext.listAvailableAnalyzers` procedure to see what options are available. " + "And '" + PROCEDURE_EVENTUALLY_CONSISTENT + "' which can be set to 'true' to make this index eventually consistent, " + "such that updates from committing transactions are applied in a background thread.")
@Procedure(name = "db.index.fulltext.createNodeIndex", mode = SCHEMA, deprecatedBy = "CREATE FULLTEXT INDEX command")
public void createNodeFulltextIndex(@Name("indexName") String name, @Name("labels") List<String> labelNames, @Name("properties") List<String> properties, @Name(value = "config", defaultValue = "{}") Map<String, String> config) {
Label[] labels = labelNames.stream().map(Label::label).toArray(Label[]::new);
IndexCreator indexCreator = transaction.schema().indexFor(labels);
createIndex(indexCreator, name, properties, config);
}
use of org.neo4j.graphdb.schema.IndexCreator in project neo4j by neo4j.
the class SchemaAcceptanceTest method indexSettingsWithNonsensicalValuesMustBeRejected.
@Test
void indexSettingsWithNonsensicalValuesMustBeRejected() {
try (Transaction tx = db.beginTx()) {
Exception e;
IndexCreator creator = tx.schema().indexFor(label).withName("my_index").on(propertyKey);
e = assertThrows(IllegalArgumentException.class, () -> creator.withIndexType(IndexType.FULLTEXT).withIndexConfiguration(Map.of(IndexSettingImpl.FULLTEXT_ANALYZER, "analyzer that does not exist")).create());
assertThat(e).hasMessageContaining("'analyzer that does not exist'");
e = assertThrows(IllegalArgumentException.class, () -> creator.withIndexConfiguration(Map.of(IndexSettingImpl.SPATIAL_CARTESIAN_MAX, new double[] { 100.0, 10.0, 1.0 })).create());
assertThat(e).hasMessageContaining("Invalid spatial index settings");
tx.commit();
}
}
use of org.neo4j.graphdb.schema.IndexCreator in project neo4j by neo4j.
the class SchemaAcceptanceTest method createIndexNoWait.
static IndexDefinition createIndexNoWait(GraphDatabaseService db, String name, 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);
}
if (name != null) {
indexCreator = indexCreator.withName(name);
}
indexDef = indexCreator.create();
tx.commit();
}
return indexDef;
}
use of org.neo4j.graphdb.schema.IndexCreator in project neo4j by neo4j.
the class SchemaAcceptanceTest method mustCreateFullTextIndexBySettingIndexType.
@Test
void mustCreateFullTextIndexBySettingIndexType() {
try (Transaction tx = db.beginTx()) {
IndexCreator creator = tx.schema().indexFor(label).on(propertyKey).withIndexType(IndexType.FULLTEXT);
IndexDefinition definition = creator.create();
assertEquals(IndexType.FULLTEXT, definition.getIndexType());
IndexProviderDescriptor provider = ((IndexDefinitionImpl) definition).getIndexReference().getIndexProvider();
assertEquals(provider, FulltextIndexProviderFactory.DESCRIPTOR);
tx.commit();
}
}
Aggregations