use of org.neo4j.internal.schema.IndexConfig 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.IndexConfig 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.IndexConfig in project neo4j by neo4j.
the class SchemaStorageIT method shouldWriteAndReadIndexConfig.
@Test
void shouldWriteAndReadIndexConfig() throws KernelException {
// given
IndexConfig expected = IndexConfig.with(MapUtil.genericMap("value.string", Values.stringValue("value"), "value.int", Values.intValue(1), "value.doubleArray", Values.doubleArray(new double[] { 0.4, 0.6, 1.0 }), "value.boolean", Values.booleanValue(true)));
var cursorContext = NULL;
SchemaDescriptor schema = forLabel(labelId(LABEL1), propId(PROP1));
long id = schemaStore.nextId(cursorContext);
IndexDescriptor storeIndexDescriptor = forSchema(schema).withName("index_" + id).materialise(id).withIndexConfig(expected);
storage.writeSchemaRule(storeIndexDescriptor, cursorContext, INSTANCE);
// when
IndexDescriptor schemaRule = (IndexDescriptor) storage.loadSingleSchemaRule(id, NULL);
// Clean up after ourselves.
storage.deleteSchemaRule(schemaRule, NULL);
// then
IndexConfig actual = schemaRule.getIndexConfig();
assertEquals(expected, actual, "Read index config not same as written, expected " + expected + ", actual " + actual);
}
use of org.neo4j.internal.schema.IndexConfig in project neo4j by neo4j.
the class SpatialConfigExtractorTest method shouldBeAbleToExtractConfigFromHealthy35File.
@Test
void shouldBeAbleToExtractConfigFromHealthy35File() throws IOException {
// given
unzip(getClass(), ZIP_HEALTHY_SPATIAL_35_DIR, directory.homePath());
Path spatialDir = directory.file(HEALTHY_SPATIAL_35_DIR);
// and
assertTrue(fs.fileExists(spatialDir));
// when
List<SpatialFile> spatialFiles = IndexMigration.getSpatialFiles(fs, spatialDir);
IndexConfig indexConfig = SpatialConfigExtractor.indexConfigFromSpatialFile(pageCache, spatialFiles, NULL, NullLog.getInstance(), DEFAULT_DATABASE_NAME);
// then
assertExpectedIndexConfig(indexConfig);
}
use of org.neo4j.internal.schema.IndexConfig in project neo4j by neo4j.
the class SpatialIndexConfigTest method mustAddAndExtractSpatialConfigToIndexConfig.
@Test
void mustAddAndExtractSpatialConfigToIndexConfig() {
IndexConfig indexConfig = IndexConfig.empty();
Map<CoordinateReferenceSystem, SpaceFillingCurveSettings> expectedMap = new HashMap<>();
for (CoordinateReferenceSystem crs : CoordinateReferenceSystem.all()) {
Config config = Config.defaults();
SpaceFillingCurveSettings spaceFillingCurveSettings = new ConfiguredSpaceFillingCurveSettingsCache(config).forCRS(crs);
expectedMap.put(crs, spaceFillingCurveSettings);
indexConfig = SpatialIndexConfig.addSpatialConfig(indexConfig, crs, spaceFillingCurveSettings);
}
Map<CoordinateReferenceSystem, SpaceFillingCurveSettings> extractedMap = SpatialIndexConfig.extractSpatialConfig(indexConfig);
assertEquals(expectedMap, extractedMap);
}
Aggregations