use of org.neo4j.internal.schema.IndexPrototype in project neo4j by neo4j.
the class FulltextIndexProviderTest method createAndQueryFulltextRelationshipIndex.
@Test
void createAndQueryFulltextRelationshipIndex() throws Exception {
IndexDescriptor indexReference;
try (KernelTransactionImplementation transaction = getKernelTransaction()) {
SchemaDescriptor schema = SchemaDescriptor.fulltext(EntityType.RELATIONSHIP, new int[] { labelIdHej, labelIdHa, labelIdHe }, new int[] { propIdHej, propIdHa, propIdHe, propIdHo });
IndexPrototype prototype = IndexPrototype.forSchema(schema, DESCRIPTOR).withIndexType(FULLTEXT).withName("fulltext");
indexReference = transaction.schemaWrite().indexCreate(prototype);
transaction.success();
}
await(indexReference);
long secondRelId;
try (Transaction transaction = db.beginTx()) {
Relationship ho = transaction.getNodeById(node1.getId()).createRelationshipTo(transaction.getNodeById(node2.getId()), RelationshipType.withName("ho"));
secondRelId = ho.getId();
ho.setProperty("hej", "villa");
ho.setProperty("ho", "value3");
transaction.commit();
}
verifyRelationshipData(secondRelId);
controller.restartDbms();
verifyRelationshipData(secondRelId);
}
use of org.neo4j.internal.schema.IndexPrototype in project neo4j by neo4j.
the class FulltextIndexProviderTest method createAndRetainRelationshipFulltextIndex.
@Test
void createAndRetainRelationshipFulltextIndex() throws Exception {
IndexDescriptor indexReference;
try (KernelTransactionImplementation transaction = getKernelTransaction()) {
SchemaDescriptor schema = SchemaDescriptor.fulltext(EntityType.RELATIONSHIP, new int[] { labelIdHej, labelIdHa, labelIdHe }, new int[] { propIdHej, propIdHa, propIdHe, propIdHo });
IndexPrototype prototype = IndexPrototype.forSchema(schema, DESCRIPTOR).withIndexType(FULLTEXT).withName("fulltext");
indexReference = transaction.schemaWrite().indexCreate(prototype);
transaction.success();
}
await(indexReference);
controller.restartDbms();
verifyThatFulltextIndexIsPresent(indexReference);
}
use of org.neo4j.internal.schema.IndexPrototype in project neo4j by neo4j.
the class FulltextIndexProviderTest method validateMustThrowIfSchemaIsNotFulltext.
@Test
void validateMustThrowIfSchemaIsNotFulltext() throws Exception {
try (KernelTransactionImplementation transaction = getKernelTransaction()) {
int[] propertyIds = { propIdHa };
SchemaDescriptor schema = SchemaDescriptor.forLabel(labelIdHa, propertyIds);
IndexPrototype prototype = IndexPrototype.forSchema(schema).withIndexType(FULLTEXT).withName(NAME);
SchemaWrite schemaWrite = transaction.schemaWrite();
var e = assertThrows(IllegalArgumentException.class, () -> schemaWrite.indexCreate(prototype));
assertThat(e.getMessage()).contains("schema is not a full-text index schema");
transaction.success();
}
}
use of org.neo4j.internal.schema.IndexPrototype in project neo4j by neo4j.
the class Database method createLookupIndex.
private void createLookupIndex(KernelTransaction tx, EntityType entityType) throws KernelException {
var descriptor = SchemaDescriptor.forAnyEntityTokens(entityType);
IndexPrototype prototype = IndexPrototype.forSchema(descriptor).withIndexType(LOOKUP).withIndexProvider(indexProviderMap.getTokenIndexProvider().getProviderDescriptor());
prototype = prototype.withName(SchemaRule.generateName(prototype, new String[] {}, new String[] {}));
tx.schemaWrite().indexCreate(prototype);
}
use of org.neo4j.internal.schema.IndexPrototype in project neo4j by neo4j.
the class IndexProviderTests method validatePrototypeMustAcceptValidPrototype.
/* validatePrototype */
@Test
void validatePrototypeMustAcceptValidPrototype() {
// given
provider = newProvider();
// when
IndexPrototype validPrototype = validPrototype();
// then
assertDoesNotThrow(() -> provider.validatePrototype(validPrototype));
}
Aggregations