use of org.neo4j.kernel.impl.api.KernelTransactionImplementation in project neo4j by neo4j.
the class FulltextAnalyzerTest method shouldNotReindexNodesWhenDefaultAnalyzerIsChanged.
@Test
void shouldNotReindexNodesWhenDefaultAnalyzerIsChanged() throws Exception {
long secondID;
applySetting(FulltextSettings.fulltext_default_analyzer, ENGLISH);
try (Transaction tx = db.beginTx()) {
tx.schema().indexFor(LABEL).on(PROP).withIndexType(FULLTEXT).withName("nodes").create();
tx.commit();
}
try (Transaction tx = db.beginTx()) {
tx.schema().awaitIndexOnline("nodes", 1, TimeUnit.MINUTES);
}
try (Transaction tx = db.beginTx()) {
createNodeIndexableByPropertyValue(tx, LABEL, "Hello and hello again, in the end.");
secondID = createNodeIndexableByPropertyValue(tx, LABEL, "En apa och en tomte bodde i ett hus.");
tx.commit();
}
try (Transaction tx = db.beginTx()) {
KernelTransaction ktx = kernelTransaction(tx);
assertQueryFindsNothing(ktx, true, "nodes", "and");
assertQueryFindsNothing(ktx, true, "nodes", "in");
assertQueryFindsNothing(ktx, true, "nodes", "the");
assertQueryFindsIds(ktx, true, "nodes", "en", secondID);
assertQueryFindsIds(ktx, true, "nodes", "och", secondID);
assertQueryFindsIds(ktx, true, "nodes", "ett", secondID);
}
applySetting(FulltextSettings.fulltext_default_analyzer, SWEDISH);
try (KernelTransactionImplementation ktx = getKernelTransaction()) {
SchemaRead schemaRead = ktx.schemaRead();
await(schemaRead.indexGetForName("nodes"));
// These results should be exactly the same as before the configuration change and restart.
assertQueryFindsNothing(ktx, true, "nodes", "and");
assertQueryFindsNothing(ktx, true, "nodes", "in");
assertQueryFindsNothing(ktx, true, "nodes", "the");
assertQueryFindsIds(ktx, true, "nodes", "en", secondID);
assertQueryFindsIds(ktx, true, "nodes", "och", secondID);
assertQueryFindsIds(ktx, true, "nodes", "ett", secondID);
}
}
use of org.neo4j.kernel.impl.api.KernelTransactionImplementation 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.kernel.impl.api.KernelTransactionImplementation 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.kernel.impl.api.KernelTransactionImplementation 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.kernel.impl.api.KernelTransactionImplementation in project neo4j by neo4j.
the class PlainOperationsTest method shouldAcquireTxStateBeforeAllocatingRelationshipId.
@Test
void shouldAcquireTxStateBeforeAllocatingRelationshipId() throws EntityNotFoundException {
// given
KernelTransactionImplementation ktx = mock(KernelTransactionImplementation.class);
when(ktx.txState()).thenReturn(mock(TransactionState.class));
Locks.Client lockClient = mock(Locks.Client.class);
when(ktx.lockClient()).thenReturn(lockClient);
when(ktx.securityContext()).thenReturn(SecurityContext.AUTH_DISABLED);
when(ktx.securityAuthorizationHandler()).thenReturn(new SecurityAuthorizationHandler(CommunitySecurityLog.NULL_LOG));
CommandCreationContext commandCreationContext = mock(CommandCreationContext.class);
AllStoreHolder allStoreHolder = mock(AllStoreHolder.class);
when(allStoreHolder.nodeExists(anyLong())).thenReturn(true);
Operations operations = new Operations(allStoreHolder, mock(StorageReader.class), mock(IndexTxStateUpdater.class), commandCreationContext, ktx, mock(KernelToken.class), mock(DefaultPooledCursors.class), mock(ConstraintIndexCreator.class), mock(ConstraintSemantics.class), mock(IndexingProvidersService.class), Config.defaults(), INSTANCE, () -> KernelVersion.LATEST, mock(DbmsRuntimeRepository.class));
// when
operations.relationshipCreate(0, 1, 2);
// then
InOrder inOrder = inOrder(ktx, commandCreationContext);
inOrder.verify(ktx).txState();
inOrder.verify(commandCreationContext).reserveRelationship();
inOrder.verifyNoMoreInteractions();
}
Aggregations