use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.
the class IndexingServiceIntegrationTest method dropIndexDirectlyOnIndexingServiceRaceWithCheckpoint.
@ParameterizedTest
@MethodSource("parameters")
void dropIndexDirectlyOnIndexingServiceRaceWithCheckpoint(GraphDatabaseSettings.SchemaIndex schemaIndex) throws Throwable {
setUp(schemaIndex);
IndexingService indexingService = getIndexingService(database);
CheckPointer checkPointer = getCheckPointer(database);
IndexDescriptor indexDescriptor;
try (Transaction tx = database.beginTx()) {
IndexDefinitionImpl indexDefinition = (IndexDefinitionImpl) tx.schema().indexFor(Label.label("label")).on("prop").create();
indexDescriptor = indexDefinition.getIndexReference();
tx.commit();
}
try (Transaction tx = database.beginTx()) {
tx.schema().awaitIndexesOnline(1, TimeUnit.HOURS);
tx.commit();
}
Race race = new Race();
race.addContestant(Race.throwing(() -> checkPointer.forceCheckPoint(new SimpleTriggerInfo("Test force"))));
race.addContestant(Race.throwing(() -> indexingService.dropIndex(indexDescriptor)));
race.go();
}
use of org.neo4j.internal.schema.IndexDescriptor 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.IndexDescriptor 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.IndexDescriptor in project neo4j by neo4j.
the class FulltextIndexProviderTest method shouldAnswerStartsWithIfCypherCompatible.
@Test
void shouldAnswerStartsWithIfCypherCompatible() throws KernelException {
IndexDescriptor indexReference;
Label containsLabel = label("containsLabel");
String containsProp = "containsProp";
long nodea;
long nodeapa1;
long nodeapa2;
long nodeapaapa;
long nodeapalong;
try (Transaction tx = db.beginTx()) {
nodea = createNode(tx, containsLabel, containsProp, "a");
createNode(tx, containsLabel, containsProp, "A");
nodeapa1 = createNode(tx, containsLabel, containsProp, "apa");
nodeapa2 = createNode(tx, containsLabel, containsProp, "apa");
createNode(tx, containsLabel, containsProp, "longapa");
nodeapaapa = createNode(tx, containsLabel, containsProp, "apa apa");
nodeapalong = createNode(tx, containsLabel, containsProp, "apalong");
tx.commit();
}
int containsLabelId;
int containsPropertyId;
try (Transaction tx = db.beginTx()) {
TokenRead tokenRead = tokenRead(tx);
containsLabelId = tokenRead.nodeLabel(containsLabel.name());
containsPropertyId = tokenRead.propertyKey(containsProp);
}
indexReference = createIndex(new int[] { containsLabelId }, new int[] { containsPropertyId }, "cypher");
await(indexReference);
try (Transaction tx = db.beginTx()) {
KernelTransaction ktx = LuceneFulltextTestSupport.kernelTransaction(tx);
assertQueryResult(ktx, startsWithQuery(containsPropertyId, "a"), nodea, nodeapa1, nodeapa2, nodeapaapa, nodeapalong);
assertQueryResult(ktx, startsWithQuery(containsPropertyId, "apa"), nodeapa1, nodeapa2, nodeapalong, nodeapaapa);
assertQueryResult(ktx, startsWithQuery(containsPropertyId, "apa*"));
assertQueryResult(ktx, startsWithQuery(containsPropertyId, "apa a"), nodeapaapa);
assertQueryResult(ktx, startsWithQuery(containsPropertyId, "*apa"));
}
controller.restartDbms();
try (Transaction tx = db.beginTx()) {
KernelTransaction ktx = LuceneFulltextTestSupport.kernelTransaction(tx);
assertQueryResult(ktx, startsWithQuery(containsPropertyId, "a"), nodea, nodeapa1, nodeapa2, nodeapaapa, nodeapalong);
assertQueryResult(ktx, startsWithQuery(containsPropertyId, "apa"), nodeapa1, nodeapa2, nodeapalong, nodeapaapa);
assertQueryResult(ktx, startsWithQuery(containsPropertyId, "apa*"));
assertQueryResult(ktx, startsWithQuery(containsPropertyId, "apa a"), nodeapaapa);
assertQueryResult(ktx, startsWithQuery(containsPropertyId, "*apa"));
}
}
use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.
the class FulltextIndexProviderTest method shouldThrowOnCypherFulltextQueryIfNotCypherCompatibleAnalyzer.
@Test
void shouldThrowOnCypherFulltextQueryIfNotCypherCompatibleAnalyzer() throws KernelException {
IndexDescriptor indexReference = createIndex(new int[] { labelIdHa }, new int[] { propIdHa }, "english");
await(indexReference);
try (Transaction tx = db.beginTx()) {
KernelTransaction ktx = LuceneFulltextTestSupport.kernelTransaction(tx);
IllegalStateException e = assertThrows(IllegalStateException.class, () -> assertQueryResult(ktx, endsWithQuery(1, "a")));
assertThat(e.getMessage()).contains("This fulltext index does not have support for Cypher semantics because configured analyzer 'english' is not Cypher compatible.");
}
}
Aggregations