diff --git a/community/kernel/src/main/java/org/neo4j/graphdb/factory/GraphDatabaseSettings.java b/community/kernel/src/main/java/org/neo4j/graphdb/factory/GraphDatabaseSettings.java index 08573747dc9c..139dec57cd0e 100644 --- a/community/kernel/src/main/java/org/neo4j/graphdb/factory/GraphDatabaseSettings.java +++ b/community/kernel/src/main/java/org/neo4j/graphdb/factory/GraphDatabaseSettings.java @@ -413,6 +413,11 @@ public class GraphDatabaseSettings implements LoadableConfig public static final Setting enable_native_schema_index = setting( "unsupported.dbms.enable_native_schema_index", BOOLEAN, TRUE ); + // Bloom index + @Internal + public static final Setting> bloom_indexed_properties = + setting( "unsupported.dbms.bloom_indexed_properties", STRING_LIST, TRUE ); + // Store settings @Description( "Make Neo4j keep the logical transaction logs for being able to backup the database. " + "Can be used for specifying the threshold to prune logical logs after. For example \"10 days\" will " + diff --git a/enterprise/bloom-index/src/main/java/org/neo4j/kernel/api/impl/bloom/BloomIndex.java b/enterprise/bloom-index/src/main/java/org/neo4j/kernel/api/impl/bloom/BloomIndex.java index 35cca918768e..bc47a3586e02 100644 --- a/enterprise/bloom-index/src/main/java/org/neo4j/kernel/api/impl/bloom/BloomIndex.java +++ b/enterprise/bloom-index/src/main/java/org/neo4j/kernel/api/impl/bloom/BloomIndex.java @@ -27,10 +27,12 @@ import java.nio.file.Paths; import org.neo4j.function.Factory; +import org.neo4j.graphdb.factory.GraphDatabaseSettings; import org.neo4j.io.fs.FileSystemAbstraction; import org.neo4j.kernel.api.impl.index.IndexWriterConfigs; import org.neo4j.kernel.api.impl.index.builder.LuceneIndexStorageBuilder; import org.neo4j.kernel.api.impl.index.partition.WritableIndexPartitionFactory; +import org.neo4j.kernel.configuration.Config; import static org.neo4j.kernel.api.impl.index.LuceneKernelExtensions.directoryFactory; @@ -40,9 +42,9 @@ public class BloomIndex implements AutoCloseable private final BloomLuceneIndex relationshipIndex; private final String[] properties; - public BloomIndex( FileSystemAbstraction fileSystem, File file, String... properties ) throws IOException + public BloomIndex( FileSystemAbstraction fileSystem, File file, Config config ) throws IOException { - this.properties = properties; + this.properties = config.get( GraphDatabaseSettings.bloom_indexed_properties ).toArray( new String[0] ); Factory population = () -> IndexWriterConfigs.population( new EnglishAnalyzer() ); WritableIndexPartitionFactory partitionFactory = new WritableIndexPartitionFactory( population ); diff --git a/enterprise/bloom-index/src/test/java/org/neo4j/kernel/api/impl/bloom/BloomLuceneIndexUpdaterTest.java b/enterprise/bloom-index/src/test/java/org/neo4j/kernel/api/impl/bloom/BloomLuceneIndexUpdaterTest.java index 1ab3218b65a9..ece01e6127a6 100644 --- a/enterprise/bloom-index/src/test/java/org/neo4j/kernel/api/impl/bloom/BloomLuceneIndexUpdaterTest.java +++ b/enterprise/bloom-index/src/test/java/org/neo4j/kernel/api/impl/bloom/BloomLuceneIndexUpdaterTest.java @@ -29,6 +29,8 @@ import org.neo4j.graphdb.Relationship; import org.neo4j.graphdb.RelationshipType; import org.neo4j.graphdb.Transaction; +import org.neo4j.graphdb.factory.GraphDatabaseSettings; +import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.internal.GraphDatabaseAPI; import org.neo4j.test.rule.DatabaseRule; import org.neo4j.test.rule.EmbeddedDatabaseRule; @@ -46,7 +48,7 @@ public class BloomLuceneIndexUpdaterTest @ClassRule public static TestDirectory testDirectory = TestDirectory.testDirectory( fileSystemRule ); @Rule - public DatabaseRule dbRule = new EmbeddedDatabaseRule(); + public DatabaseRule dbRule = new EmbeddedDatabaseRule().startLazily(); private static final Label LABEL = Label.label( "label" ); private static final RelationshipType RELTYPE = RelationshipType.withName( "type" ); @@ -54,8 +56,10 @@ public class BloomLuceneIndexUpdaterTest @Test public void shouldFindNodeWithString() throws Exception { - GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI(); - try ( BloomIndex bloomIndex = new BloomIndex( fileSystemRule, testDirectory.graphDbDir(), "prop" ) ) + GraphDatabaseAPI db = dbRule.withSetting( GraphDatabaseSettings.bloom_indexed_properties, "prop" ).getGraphDatabaseAPI(); + Config config = db.getDependencyResolver().resolveDependency( Config.class ); + config.augment( GraphDatabaseSettings.bloom_indexed_properties, "prop" ); + try ( BloomIndex bloomIndex = new BloomIndex( fileSystemRule, testDirectory.graphDbDir(), config ) ) { db.registerTransactionEventHandler( bloomIndex.getUpdater() ); @@ -88,8 +92,10 @@ public void shouldFindNodeWithString() throws Exception @Test public void shouldRepresentPropertyChanges() throws Exception { - GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI(); - try ( BloomIndex bloomIndex = new BloomIndex( fileSystemRule, testDirectory.graphDbDir(), "prop" ) ) + GraphDatabaseAPI db = dbRule.withSetting( GraphDatabaseSettings.bloom_indexed_properties, "prop" ).getGraphDatabaseAPI(); + Config config = db.getDependencyResolver().resolveDependency( Config.class ); + config.augment( GraphDatabaseSettings.bloom_indexed_properties, "prop" ); + try ( BloomIndex bloomIndex = new BloomIndex( fileSystemRule, testDirectory.graphDbDir(), config ) ) { db.registerTransactionEventHandler( bloomIndex.getUpdater() ); @@ -136,8 +142,10 @@ public void shouldRepresentPropertyChanges() throws Exception @Test public void shouldNotFindRemovedNodes() throws Exception { - GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI(); - try ( BloomIndex bloomIndex = new BloomIndex( fileSystemRule, testDirectory.graphDbDir(), "prop" ) ) + GraphDatabaseAPI db = dbRule.withSetting( GraphDatabaseSettings.bloom_indexed_properties, "prop" ).getGraphDatabaseAPI(); + Config config = db.getDependencyResolver().resolveDependency( Config.class ); + config.augment( GraphDatabaseSettings.bloom_indexed_properties, "prop" ); + try ( BloomIndex bloomIndex = new BloomIndex( fileSystemRule, testDirectory.graphDbDir(), config ) ) { db.registerTransactionEventHandler( bloomIndex.getUpdater() ); @@ -178,8 +186,10 @@ public void shouldNotFindRemovedNodes() throws Exception @Test public void shouldOnlyIndexIndexedProperties() throws Exception { - GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI(); - try ( BloomIndex bloomIndex = new BloomIndex( fileSystemRule, testDirectory.graphDbDir(), "prop" ) ) + GraphDatabaseAPI db = dbRule.withSetting( GraphDatabaseSettings.bloom_indexed_properties, "prop" ).getGraphDatabaseAPI(); + Config config = db.getDependencyResolver().resolveDependency( Config.class ); + config.augment( GraphDatabaseSettings.bloom_indexed_properties, "prop" ); + try ( BloomIndex bloomIndex = new BloomIndex( fileSystemRule, testDirectory.graphDbDir(), config ) ) { db.registerTransactionEventHandler( bloomIndex.getUpdater() ); @@ -212,8 +222,10 @@ public void shouldOnlyIndexIndexedProperties() throws Exception @Test public void shouldSearchAcrossMultipleProperties() throws Exception { - GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI(); - try ( BloomIndex bloomIndex = new BloomIndex( fileSystemRule, testDirectory.graphDbDir(), "prop", "prop2" ) ) + GraphDatabaseAPI db = dbRule.withSetting( GraphDatabaseSettings.bloom_indexed_properties, "prop, prop2" ).getGraphDatabaseAPI(); + Config config = db.getDependencyResolver().resolveDependency( Config.class ); + config.augment( GraphDatabaseSettings.bloom_indexed_properties, "prop, prop2" ); + try ( BloomIndex bloomIndex = new BloomIndex( fileSystemRule, testDirectory.graphDbDir(), config ) ) { db.registerTransactionEventHandler( bloomIndex.getUpdater() ); @@ -250,8 +262,10 @@ public void shouldSearchAcrossMultipleProperties() throws Exception @Test public void shouldOrderResultsBasedOnRelevance() throws Exception { - GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI(); - try ( BloomIndex bloomIndex = new BloomIndex( fileSystemRule, testDirectory.graphDbDir(), "first", "last" ) ) + GraphDatabaseAPI db = dbRule.withSetting( GraphDatabaseSettings.bloom_indexed_properties, "first, last" ).getGraphDatabaseAPI(); + Config config = db.getDependencyResolver().resolveDependency( Config.class ); + config.augment( GraphDatabaseSettings.bloom_indexed_properties, "first, last" ); + try ( BloomIndex bloomIndex = new BloomIndex( fileSystemRule, testDirectory.graphDbDir(), config ) ) { db.registerTransactionEventHandler( bloomIndex.getUpdater() ); @@ -296,8 +310,10 @@ public void shouldOrderResultsBasedOnRelevance() throws Exception @Test public void shouldDifferentiateNodesAndRelationships() throws Exception { - GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI(); - try ( BloomIndex bloomIndex = new BloomIndex( fileSystemRule, testDirectory.graphDbDir(), "prop" ) ) + GraphDatabaseAPI db = dbRule.withSetting( GraphDatabaseSettings.bloom_indexed_properties, "prop" ).getGraphDatabaseAPI(); + Config config = db.getDependencyResolver().resolveDependency( Config.class ); + config.augment( GraphDatabaseSettings.bloom_indexed_properties, "prop" ); + try ( BloomIndex bloomIndex = new BloomIndex( fileSystemRule, testDirectory.graphDbDir(), config ) ) { db.registerTransactionEventHandler( bloomIndex.getUpdater() );