diff --git a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextFactory.java b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextFactory.java index acbd9bdba002e..8e68986f0058f 100644 --- a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextFactory.java +++ b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextFactory.java @@ -34,6 +34,9 @@ import static org.neo4j.kernel.api.impl.index.LuceneKernelExtensions.directoryFactory; +/** + * Used for creating {@link LuceneFulltext} and registering those to a {@link FulltextProvider}. + */ public class FulltextFactory { private final FileSystemAbstraction fileSystem; @@ -41,6 +44,13 @@ public class FulltextFactory private final File storeDir; private final Analyzer analyzer; + /** + * Creates a factory for the specified location and analyzer. + * @param fileSystem The filesystem to use. + * @param storeDir Store directory of the database. + * @param analyzer The Lucene analyzer to use for the {@link LuceneFulltext} created by this factory. + * @throws IOException + */ public FulltextFactory( FileSystemAbstraction fileSystem, File storeDir, Analyzer analyzer ) throws IOException { this.analyzer = analyzer; @@ -50,11 +60,20 @@ public FulltextFactory( FileSystemAbstraction fileSystem, File storeDir, Analyze this.storeDir = storeDir; } - public void createFulltextHelper( String identifier, FulltextProvider.FULLTEXT_HELPER_TYPE type, String[] properties, FulltextProvider provider ) throws IOException + /** + * Creates an instance of {@link LuceneFulltext} and registers it with the supplied {@link FulltextProvider}. + * @param identifier The identifier of the new fulltext helper + * @param type The type of the new fulltext helper + * @param properties The properties to index + * @param provider The provider to register with + * @throws IOException + */ + public void createFulltextHelper( String identifier, FulltextProvider.FULLTEXT_HELPER_TYPE type, String[] properties, FulltextProvider provider ) + throws IOException { LuceneIndexStorageBuilder storageBuilder = LuceneIndexStorageBuilder.create(); - storageBuilder.withFileSystem( fileSystem ).withIndexIdentifier( - identifier ).withDirectoryFactory( directoryFactory( false, this.fileSystem ) ).withIndexRootFolder( Paths.get( this.storeDir.getAbsolutePath(), "fulltext" ).toFile() ); + storageBuilder.withFileSystem( fileSystem ).withIndexIdentifier( identifier ).withDirectoryFactory( + directoryFactory( false, this.fileSystem ) ).withIndexRootFolder( Paths.get( this.storeDir.getAbsolutePath(), "fulltext" ).toFile() ); provider.register( new LuceneFulltext( storageBuilder.build(), partitionFactory, properties, analyzer, identifier, type ) ); } } diff --git a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextProvider.java b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextProvider.java index 07bc331f77830..c4934c2d33670 100644 --- a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextProvider.java +++ b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextProvider.java @@ -67,7 +67,8 @@ public synchronized void close() { closed = true; db.unregisterTransactionEventHandler( fulltextTransactionEventUpdater ); - nodeIndices.values().forEach( luceneFulltextHelper -> { + nodeIndices.values().forEach( luceneFulltextHelper -> + { try { luceneFulltextHelper.close(); @@ -77,7 +78,8 @@ public synchronized void close() e.printStackTrace(); } } ); - relationshipIndices.values().forEach( luceneFulltextHelper -> { + relationshipIndices.values().forEach( luceneFulltextHelper -> + { try { luceneFulltextHelper.close(); diff --git a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextTransactionEventUpdater.java b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextTransactionEventUpdater.java index 383e3dfc7852c..c20701864c059 100644 --- a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextTransactionEventUpdater.java +++ b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/FulltextTransactionEventUpdater.java @@ -34,7 +34,7 @@ import org.neo4j.graphdb.event.TransactionData; import org.neo4j.graphdb.event.TransactionEventHandler; -public class FulltextTransactionEventUpdater implements TransactionEventHandler +class FulltextTransactionEventUpdater implements TransactionEventHandler { private FulltextProvider fulltextProvider; diff --git a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/LuceneFulltext.java b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/LuceneFulltext.java index 093ce1d7ec39c..09bf0cbac4430 100644 --- a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/LuceneFulltext.java +++ b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/LuceneFulltext.java @@ -97,7 +97,7 @@ PartitionedIndexWriter getIndexWriter( WritableFulltext writableIndex ) throws I return new PartitionedIndexWriter( writableIndex ); } - public ReadOnlyFulltext getIndexReader() throws IOException + ReadOnlyFulltext getIndexReader() throws IOException { ensureOpen(); List partitions = getPartitions(); diff --git a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/PartitionedFulltextReader.java b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/PartitionedFulltextReader.java index c22317259210f..b629e4e6a513e 100644 --- a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/PartitionedFulltextReader.java +++ b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/PartitionedFulltextReader.java @@ -55,15 +55,15 @@ private PartitionedFulltextReader( List readers ) } @Override - public PrimitiveLongIterator query( String... query ) + public PrimitiveLongIterator query( String... terms ) { - return partitionedOperation( reader -> innerQuery( reader, query ) ); + return partitionedOperation( reader -> innerQuery( reader, terms ) ); } @Override - public PrimitiveLongIterator fuzzyQuery( String... query ) + public PrimitiveLongIterator fuzzyQuery( String... terms ) { - return partitionedOperation( reader -> innerFuzzyQuery( reader, query ) ); + return partitionedOperation( reader -> innerFuzzyQuery( reader, terms ) ); } private PrimitiveLongIterator innerQuery( ReadOnlyFulltext reader, String... query ) diff --git a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/ReadOnlyFulltext.java b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/ReadOnlyFulltext.java index 2fe9ed0f5d54e..dbd80bf79d1a9 100644 --- a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/ReadOnlyFulltext.java +++ b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/ReadOnlyFulltext.java @@ -23,6 +23,19 @@ public interface ReadOnlyFulltext extends AutoCloseable { - PrimitiveLongIterator query( String... query ); - PrimitiveLongIterator fuzzyQuery( String... query ); + /** + * Searches the fulltext helper for any exact match of any of the given terms against any token in any of the indexed properties. + * + * @param terms The terms to query for. + * @return An iterator over the matching entityIDs, ordered by lucene scoring of the match. + */ + PrimitiveLongIterator query( String... terms ); + + /** + * Searches the fulltext helper for any fuzzy match of any of the given terms against any token in any of the indexed properties. + * + * @param terms The terms to query for. + * @return An iterator over the matching entityIDs, ordered by lucene scoring of the match. + */ + PrimitiveLongIterator fuzzyQuery( String... terms ); } diff --git a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/SimpleFulltextReader.java b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/SimpleFulltextReader.java index 825f466e938f5..4112026cbbd1e 100644 --- a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/SimpleFulltextReader.java +++ b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/SimpleFulltextReader.java @@ -57,18 +57,18 @@ class SimpleFulltextReader implements ReadOnlyFulltext } @Override - public PrimitiveLongIterator query( String... tokens ) + public PrimitiveLongIterator query( String... terms ) { MultiFieldQueryParser multiFieldQueryParser = new MultiFieldQueryParser( properties, analyzer ); multiFieldQueryParser.setDefaultOperator( QueryParser.Operator.OR ); Query query; try { - query = multiFieldQueryParser.parse( String.join( " ", tokens ) ); + query = multiFieldQueryParser.parse( String.join( " ", terms ) ); } catch ( ParseException e ) { - query = parseFallbackBooleanQuery( multiFieldQueryParser, tokens ); + query = parseFallbackBooleanQuery( multiFieldQueryParser, terms ); } return query( query ); } @@ -93,18 +93,18 @@ private Query parseFallbackBooleanQuery( MultiFieldQueryParser multiFieldQueryPa } @Override - public PrimitiveLongIterator fuzzyQuery( String... tokens ) + public PrimitiveLongIterator fuzzyQuery( String... terms ) { MultiFieldQueryParser multiFieldQueryParser = new MultiFieldQueryParser( properties, analyzer ); multiFieldQueryParser.setDefaultOperator( QueryParser.Operator.OR ); Query query; try { - query = multiFieldQueryParser.parse( String.join( "~ ", tokens ) + "~" ); + query = multiFieldQueryParser.parse( String.join( "~ ", terms ) + "~" ); } catch ( ParseException e ) { - query = parseFallbackBooleanQuery( multiFieldQueryParser, tokens ); + query = parseFallbackBooleanQuery( multiFieldQueryParser, terms ); } return query( query ); } diff --git a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/WritableFulltext.java b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/WritableFulltext.java index 8d2c9f235d818..b6c313a2e3552 100644 --- a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/WritableFulltext.java +++ b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/WritableFulltext.java @@ -42,16 +42,6 @@ PartitionedIndexWriter getIndexWriter() throws IOException return luceneFulltext.getIndexWriter( this ); } - public boolean hasSinglePartition( List partitions ) - { - return luceneIndex.hasSinglePartition( partitions ); - } - - public AbstractIndexPartition getFirstPartition( List partitions ) - { - return luceneIndex.getFirstPartition( partitions ); - } - Set properties() { return luceneIndex.getProperties(); diff --git a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/integrations/bloom/BloomKernelExtensionFactory.java b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/integrations/bloom/BloomKernelExtensionFactory.java index 863390a61b789..14a0195bfca32 100644 --- a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/integrations/bloom/BloomKernelExtensionFactory.java +++ b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/integrations/bloom/BloomKernelExtensionFactory.java @@ -27,6 +27,12 @@ import org.neo4j.kernel.impl.spi.KernelContext; import org.neo4j.kernel.lifecycle.Lifecycle; +/** + * A {@link KernelExtensionFactory} for the bloom fulltext addon. + * + * @see BloomProcedure + * @see LoadableBloomFulltextConfig + */ public class BloomKernelExtensionFactory extends KernelExtensionFactory { diff --git a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/integrations/bloom/BloomProcedure.java b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/integrations/bloom/BloomProcedure.java index edb145a879e10..a38757d700753 100644 --- a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/integrations/bloom/BloomProcedure.java +++ b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/integrations/bloom/BloomProcedure.java @@ -34,6 +34,9 @@ import static org.neo4j.kernel.api.proc.ProcedureSignature.procedureSignature; +/** + * Procedures for querying the bloom fulltext addon. + */ public class BloomProcedure extends CallableProcedure.BasicProcedure { private static final String OUTPUT_NAME = "entityid"; @@ -43,6 +46,12 @@ public class BloomProcedure extends CallableProcedure.BasicProcedure private final FulltextProvider provider; private FulltextProvider.FULLTEXT_HELPER_TYPE type; + /** + * Creates a procedure for querying the bloom fulltext addon. + * @param type The type of fulltext helper to be queried. + * @param identifier The identifier of the fulltext helper. + * @param provider The provider of the fulltext helper. + */ public BloomProcedure( FulltextProvider.FULLTEXT_HELPER_TYPE type, String identifier, FulltextProvider provider ) { super( procedureSignature( new QualifiedName( PROCEDURE_NAMESPACE, PROCEDURE_NAME + type ) ).in( "terms", diff --git a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/integrations/bloom/LoadableBloomFulltextConfig.java b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/integrations/bloom/LoadableBloomFulltextConfig.java index ded9087c89455..bedf3c29eedd3 100644 --- a/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/integrations/bloom/LoadableBloomFulltextConfig.java +++ b/enterprise/fulltext-addon/src/main/java/org/neo4j/kernel/api/impl/fulltext/integrations/bloom/LoadableBloomFulltextConfig.java @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2002-2017 "Neo Technology," + * Network Engine for Objects in Lund AB [http://neotechnology.com] + * + * This file is part of Neo4j. + * + * Neo4j is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ package org.neo4j.kernel.api.impl.fulltext.integrations.bloom; import java.util.List; @@ -12,6 +31,9 @@ import static org.neo4j.kernel.configuration.Settings.STRING_LIST; import static org.neo4j.kernel.configuration.Settings.setting; +/** + * Configuration parameters for the bloom fulltext addon. + */ public class LoadableBloomFulltextConfig implements LoadableConfig { diff --git a/enterprise/fulltext-addon/src/test/java/org/neo4j/kernel/api/impl/fulltext/FulltextAnalyzerTest.java b/enterprise/fulltext-addon/src/test/java/org/neo4j/kernel/api/impl/fulltext/FulltextAnalyzerTest.java index 3804ee96b85d2..4926778fba654 100644 --- a/enterprise/fulltext-addon/src/test/java/org/neo4j/kernel/api/impl/fulltext/FulltextAnalyzerTest.java +++ b/enterprise/fulltext-addon/src/test/java/org/neo4j/kernel/api/impl/fulltext/FulltextAnalyzerTest.java @@ -119,4 +119,4 @@ public void shouldBeAbleToSpecifySwedishAnalyzer() throws Exception } } } -} \ No newline at end of file +}