use of org.neo4j.internal.schema.FulltextSchemaDescriptor in project neo4j by neo4j.
the class LuceneFulltextIndexTest method completeConfigurationMustNotOverwriteExistingConfiguration.
@Test
void completeConfigurationMustNotOverwriteExistingConfiguration() {
IndexConfig indexConfig = IndexConfig.with("A", Values.stringValue("B"));
FulltextSchemaDescriptor schema = SchemaDescriptor.fulltext(NODE, new int[] { 1 }, new int[] { 1 });
IndexProviderDescriptor providerDescriptor = indexProvider.getProviderDescriptor();
IndexDescriptor descriptor = indexProvider.completeConfiguration(IndexPrototype.forSchema(schema, providerDescriptor).withName("index_1").materialise(1)).withIndexConfig(indexConfig);
assertEquals(Values.stringValue("B"), descriptor.getIndexConfig().get("A"));
}
use of org.neo4j.internal.schema.FulltextSchemaDescriptor in project neo4j by neo4j.
the class LuceneFulltextIndexTest method completeConfigurationMustInjectMissingConfigurations.
@Test
void completeConfigurationMustInjectMissingConfigurations() throws Exception {
int label;
int propertyKey;
try (Transaction tx = db.beginTx()) {
createNodeIndexableByPropertyValue(tx, LABEL, "bla");
tx.commit();
}
try (KernelTransactionImplementation tx = getKernelTransaction()) {
label = tx.tokenRead().nodeLabel(LABEL.name());
propertyKey = tx.tokenRead().propertyKey(PROP);
tx.success();
}
IndexConfig indexConfig = IndexConfig.with(EVENTUALLY_CONSISTENT, Values.booleanValue(true));
FulltextSchemaDescriptor schema = SchemaDescriptor.fulltext(NODE, new int[] { label }, new int[] { propertyKey });
IndexProviderDescriptor providerDescriptor = indexProvider.getProviderDescriptor();
IndexDescriptor descriptor = indexProvider.completeConfiguration(IndexPrototype.forSchema(schema, providerDescriptor).withName("index_1").withIndexConfig(indexConfig).materialise(1));
assertThat((Value) descriptor.getIndexConfig().get(ANALYZER)).isEqualTo(Values.stringValue("standard-no-stop-words"));
assertThat((Value) descriptor.getIndexConfig().get(EVENTUALLY_CONSISTENT)).isEqualTo(Values.booleanValue(true));
assertThat(asList(descriptor.getCapability().behaviours())).containsExactlyInAnyOrder(IndexBehaviour.EVENTUALLY_CONSISTENT, IndexBehaviour.SKIP_AND_LIMIT);
}
use of org.neo4j.internal.schema.FulltextSchemaDescriptor in project neo4j by neo4j.
the class IndexCreateIT method shouldFailCreateIndexWithDuplicateProperties.
@Test
void shouldFailCreateIndexWithDuplicateProperties() throws KernelException {
// given
TokenWrite tokenWrite = tokenWriteInNewTransaction();
int labelId = tokenWrite.labelGetOrCreateForName("Label");
int propId = tokenWrite.propertyKeyGetOrCreateForName("property");
commit();
SchemaWrite schemaWrite = schemaWriteInNewTransaction();
// when
final FulltextSchemaDescriptor descriptor = SchemaDescriptor.fulltext(EntityType.NODE, new int[] { labelId }, new int[] { propId, propId });
// then
assertThrows(RepeatedPropertyInSchemaException.class, () -> schemaWrite.indexCreate(descriptor, null));
}
use of org.neo4j.internal.schema.FulltextSchemaDescriptor in project neo4j by neo4j.
the class IndexCreateIT method shouldFailCreateIndexWithDuplicateRelationshipTypes.
@Test
void shouldFailCreateIndexWithDuplicateRelationshipTypes() throws KernelException {
// given
TokenWrite tokenWrite = tokenWriteInNewTransaction();
int relTypeId = tokenWrite.relationshipTypeGetOrCreateForName("RELATIONSHIP");
int propId = tokenWrite.propertyKeyGetOrCreateForName("property");
commit();
SchemaWrite schemaWrite = schemaWriteInNewTransaction();
// when
final FulltextSchemaDescriptor descriptor = SchemaDescriptor.fulltext(EntityType.RELATIONSHIP, new int[] { relTypeId, relTypeId }, new int[] { propId });
// then
assertThrows(RepeatedRelationshipTypeInSchemaException.class, () -> schemaWrite.indexCreate(descriptor, null));
}
use of org.neo4j.internal.schema.FulltextSchemaDescriptor in project neo4j by neo4j.
the class IndexCreateIT method shouldFailCreateIndexWithDuplicateLabels.
@Test
void shouldFailCreateIndexWithDuplicateLabels() throws KernelException {
// given
TokenWrite tokenWrite = tokenWriteInNewTransaction();
int labelId = tokenWrite.labelGetOrCreateForName("Label");
int propId = tokenWrite.propertyKeyGetOrCreateForName("property");
commit();
SchemaWrite schemaWrite = schemaWriteInNewTransaction();
// when
final FulltextSchemaDescriptor descriptor = SchemaDescriptor.fulltext(EntityType.NODE, new int[] { labelId, labelId }, new int[] { propId });
// then
assertThrows(RepeatedLabelInSchemaException.class, () -> schemaWrite.indexCreate(descriptor, null));
}
Aggregations