Search in sources :

Example 1 with FulltextSchemaDescriptor

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"));
}
Also used : IndexConfig(org.neo4j.internal.schema.IndexConfig) IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor) FulltextSchemaDescriptor(org.neo4j.internal.schema.FulltextSchemaDescriptor) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Test(org.junit.jupiter.api.Test)

Example 2 with FulltextSchemaDescriptor

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);
}
Also used : IndexConfig(org.neo4j.internal.schema.IndexConfig) Transaction(org.neo4j.graphdb.Transaction) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) KernelTransactionImplementation(org.neo4j.kernel.impl.api.KernelTransactionImplementation) IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor) Value(org.neo4j.values.storable.Value) FulltextSchemaDescriptor(org.neo4j.internal.schema.FulltextSchemaDescriptor) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Test(org.junit.jupiter.api.Test)

Example 3 with FulltextSchemaDescriptor

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));
}
Also used : SchemaWrite(org.neo4j.internal.kernel.api.SchemaWrite) FulltextSchemaDescriptor(org.neo4j.internal.schema.FulltextSchemaDescriptor) TokenWrite(org.neo4j.internal.kernel.api.TokenWrite) Test(org.junit.jupiter.api.Test) KernelIntegrationTest(org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest)

Example 4 with FulltextSchemaDescriptor

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));
}
Also used : SchemaWrite(org.neo4j.internal.kernel.api.SchemaWrite) FulltextSchemaDescriptor(org.neo4j.internal.schema.FulltextSchemaDescriptor) TokenWrite(org.neo4j.internal.kernel.api.TokenWrite) Test(org.junit.jupiter.api.Test) KernelIntegrationTest(org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest)

Example 5 with FulltextSchemaDescriptor

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));
}
Also used : SchemaWrite(org.neo4j.internal.kernel.api.SchemaWrite) FulltextSchemaDescriptor(org.neo4j.internal.schema.FulltextSchemaDescriptor) TokenWrite(org.neo4j.internal.kernel.api.TokenWrite) Test(org.junit.jupiter.api.Test) KernelIntegrationTest(org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest)

Aggregations

Test (org.junit.jupiter.api.Test)12 FulltextSchemaDescriptor (org.neo4j.internal.schema.FulltextSchemaDescriptor)12 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)9 IndexProviderDescriptor (org.neo4j.internal.schema.IndexProviderDescriptor)5 SchemaWrite (org.neo4j.internal.kernel.api.SchemaWrite)3 TokenWrite (org.neo4j.internal.kernel.api.TokenWrite)3 KernelIntegrationTest (org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest)3 IndexConfig (org.neo4j.internal.schema.IndexConfig)2 Value (org.neo4j.values.storable.Value)2 Transaction (org.neo4j.graphdb.Transaction)1 NodeCommand (org.neo4j.internal.recordstorage.Command.NodeCommand)1 PropertyCommand (org.neo4j.internal.recordstorage.Command.PropertyCommand)1 IndexCapability (org.neo4j.internal.schema.IndexCapability)1 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)1 KernelTransactionImplementation (org.neo4j.kernel.impl.api.KernelTransactionImplementation)1 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)1 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)1 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)1 ValueCategory (org.neo4j.values.storable.ValueCategory)1