Skip to content

Commit

Permalink
All available fulltext schema index analyzers now have useful descrip…
Browse files Browse the repository at this point in the history
…tions explaining what they do and what they are for.
  • Loading branch information
chrisvest committed Dec 21, 2018
1 parent 37510e6 commit 5f1bef7
Show file tree
Hide file tree
Showing 46 changed files with 300 additions and 7 deletions.
Expand Up @@ -702,6 +702,7 @@ public void mustBeAbleToListAvailableAnalyzers()
{
db = createDatabase();

// Verify that a couple of expected analyzers are available.
try ( Transaction tx = db.beginTx() )
{
Set<String> analyzers = new HashSet<>();
Expand All @@ -717,6 +718,24 @@ public void mustBeAbleToListAvailableAnalyzers()
assertThat( analyzers, hasItem( "standard" ) );
tx.success();
}

// Verify that all analyzers have a description.
try ( Transaction tx = db.beginTx() )
{
try ( Result result = db.execute( LIST_AVAILABLE_ANALYZERS ) )
{
while ( result.hasNext() )
{
Map<String,Object> row = result.next();
Object description = row.get( "description" );
if ( !row.containsKey( "description" ) || !(description instanceof String) || ((String) description).trim().isEmpty() )
{
fail( "Found no description for analyzer: " + row );
}
}
}
tx.success();
}
}

@Test
Expand Down
Expand Up @@ -25,6 +25,7 @@
import java.util.Properties;
import java.util.stream.Stream;

import org.neo4j.graphdb.index.fulltext.AnalyzerProvider;
import org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException;
import org.neo4j.internal.kernel.api.schema.SchemaDescriptor;
import org.neo4j.kernel.api.KernelTransaction;
Expand All @@ -38,5 +39,5 @@ public interface FulltextAdapter

void awaitRefresh();

Stream<String> listAvailableAnalyzers();
Stream<AnalyzerProvider> listAvailableAnalyzers();
}
Expand Up @@ -327,11 +327,10 @@ public void awaitRefresh()
}

@Override
public Stream<String> listAvailableAnalyzers()
public Stream<AnalyzerProvider> listAvailableAnalyzers()
{
Iterable<AnalyzerProvider> providers = AnalyzerProvider.load( AnalyzerProvider.class );
Stream<AnalyzerProvider> stream = StreamSupport.stream( providers.spliterator(), false );
return stream.flatMap( provider -> StreamSupport.stream( provider.getKeys().spliterator(), false ) );
return StreamSupport.stream( providers.spliterator(), false );
}

@Override
Expand Down
Expand Up @@ -28,14 +28,17 @@
import java.util.Objects;
import java.util.Optional;
import java.util.Properties;
import java.util.Spliterator;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

import org.neo4j.graphdb.DependencyResolver;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.NotFoundException;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.index.fulltext.AnalyzerProvider;
import org.neo4j.graphdb.schema.IndexDefinition;
import org.neo4j.graphdb.schema.Schema;
import org.neo4j.internal.kernel.api.IndexReference;
Expand Down Expand Up @@ -87,7 +90,13 @@ public class FulltextProcedures
@Procedure( name = "db.index.fulltext.listAvailableAnalyzers", mode = READ )
public Stream<AvailableAnalyzer> listAvailableAnalyzers()
{
return accessor.listAvailableAnalyzers().map( AvailableAnalyzer::new );
Stream<AnalyzerProvider> stream = accessor.listAvailableAnalyzers();
return stream.flatMap( provider ->
{
String description = provider.description();
Spliterator<String> spliterator = provider.getKeys().spliterator();
return StreamSupport.stream( spliterator, false ).map( name -> new AvailableAnalyzer( name, description ) );
} );
}

@Description( "Wait for the updates from recently committed transactions to be applied to any eventually-consistent fulltext indexes." )
Expand Down Expand Up @@ -285,10 +294,12 @@ public static RelationshipOutput forExistingEntityOrNull( GraphDatabaseService d
public static final class AvailableAnalyzer
{
public final String analyzer;
public final String description;

AvailableAnalyzer( String analyzer )
AvailableAnalyzer( String name, String description )
{
this.analyzer = analyzer;
this.analyzer = name;
this.description = description;
}
}
}
Expand Up @@ -38,4 +38,10 @@ public Analyzer createAnalyzer()
{
return new ArabicAnalyzer();
}

@Override
public String description()
{
return "Arabic analyzer with light stemming, as specified by \"Light Stemming for Arabic Information Retrieval\".";
}
}
Expand Up @@ -38,4 +38,10 @@ public Analyzer createAnalyzer()
{
return new ArmenianAnalyzer();
}

@Override
public String description()
{
return "Armenian analyzer with stemming and stop word filtering.";
}
}
Expand Up @@ -38,4 +38,10 @@ public Analyzer createAnalyzer()
{
return new BasqueAnalyzer();
}

@Override
public String description()
{
return "Basque analyzer with stemming and stop word filtering.";
}
}
Expand Up @@ -38,4 +38,10 @@ public Analyzer createAnalyzer()
{
return new BrazilianAnalyzer();
}

@Override
public String description()
{
return "Brazilian Portuguese analyzer with stemming and stop word filtering.";
}
}
Expand Up @@ -38,4 +38,10 @@ public Analyzer createAnalyzer()
{
return new BulgarianAnalyzer();
}

@Override
public String description()
{
return "Bulgarian analyzer with light stemming, as specified by \"Searching Strategies for the Bulgarian Language\", and stop word filtering.";
}
}
Expand Up @@ -38,4 +38,10 @@ public Analyzer createAnalyzer()
{
return new CJKAnalyzer();
}

@Override
public String description()
{
return "CJK - Chinese/Japanese/Korean - analyzer. Terms are normalised and case-folded. Produces bi-grams, and filters out stop words.";
}
}
Expand Up @@ -38,4 +38,10 @@ public Analyzer createAnalyzer()
{
return new CatalanAnalyzer();
}

@Override
public String description()
{
return "Catalan analyzer with stemming and stop word filtering.";
}
}
Expand Up @@ -38,4 +38,10 @@ public Analyzer createAnalyzer()
{
return new ClassicAnalyzer();
}

@Override
public String description()
{
return "Classic Lucene analyzer. Similar to 'standard', but with worse unicode support.";
}
}
Expand Up @@ -38,4 +38,10 @@ public Analyzer createAnalyzer()
{
return new CzechAnalyzer();
}

@Override
public String description()
{
return "Czech analyzer with stemming and stop word filtering.";
}
}
Expand Up @@ -38,4 +38,10 @@ public Analyzer createAnalyzer()
{
return new DanishAnalyzer();
}

@Override
public String description()
{
return "Danish analyzer with stemming and stop word filtering.";
}
}
Expand Up @@ -38,4 +38,10 @@ public Analyzer createAnalyzer()
{
return new DutchAnalyzer();
}

@Override
public String description()
{
return "Dutch analyzer with stemming and stop word filtering.";
}
}
Expand Up @@ -38,4 +38,10 @@ public Analyzer createAnalyzer()
{
return new EnglishAnalyzer();
}

@Override
public String description()
{
return "English analyzer with stemming and stop word filtering.";
}
}
Expand Up @@ -38,4 +38,10 @@ public Analyzer createAnalyzer()
{
return new FinnishAnalyzer();
}

@Override
public String description()
{
return "Finnish analyzer with stemming and stop word filtering.";
}
}
Expand Up @@ -38,4 +38,10 @@ public Analyzer createAnalyzer()
{
return new FrenchAnalyzer();
}

@Override
public String description()
{
return "French analyzer with stemming and stop word filtering.";
}
}
Expand Up @@ -38,4 +38,10 @@ public Analyzer createAnalyzer()
{
return new GalicianAnalyzer();
}

@Override
public String description()
{
return "Galician analyzer with stemming and stop word filtering.";
}
}
Expand Up @@ -38,4 +38,10 @@ public Analyzer createAnalyzer()
{
return new GermanAnalyzer();
}

@Override
public String description()
{
return "German analyzer with stemming and stop word filtering.";
}
}
Expand Up @@ -38,4 +38,10 @@ public Analyzer createAnalyzer()
{
return new GreekAnalyzer();
}

@Override
public String description()
{
return "Greek analyzer with stemming and stop word filtering.";
}
}
Expand Up @@ -38,4 +38,10 @@ public Analyzer createAnalyzer()
{
return new HindiAnalyzer();
}

@Override
public String description()
{
return "Hindi analyzer with stemming, normalization, and stop word filtering.";
}
}
Expand Up @@ -38,4 +38,10 @@ public Analyzer createAnalyzer()
{
return new HungarianAnalyzer();
}

@Override
public String description()
{
return "Hungarian analyzer with stemming and stop word filtering.";
}
}
Expand Up @@ -38,4 +38,10 @@ public Analyzer createAnalyzer()
{
return new IndonesianAnalyzer();
}

@Override
public String description()
{
return "Indonesian analyzer with stemming and stop word filtering.";
}
}
Expand Up @@ -38,4 +38,10 @@ public Analyzer createAnalyzer()
{
return new IrishAnalyzer();
}

@Override
public String description()
{
return "Irish analyzer with stemming and stop word filtering.";
}
}
Expand Up @@ -38,4 +38,10 @@ public Analyzer createAnalyzer()
{
return new ItalianAnalyzer();
}

@Override
public String description()
{
return "Italian analyzer with stemming and stop word filtering.";
}
}
Expand Up @@ -38,4 +38,11 @@ public Analyzer createAnalyzer()
{
return new KeywordAnalyzer();
}

@Override
public String description()
{
return "Keyword analyzer \"tokenizes\" the text as a single term. Useful for zip-codes, ids, etc. " +
"Situations where complete and exact matches are desired.";
}
}
Expand Up @@ -38,4 +38,10 @@ public Analyzer createAnalyzer()
{
return new LatvianAnalyzer();
}

@Override
public String description()
{
return "Latvian analyzer with stemming and stop word filtering.";
}
}
Expand Up @@ -38,4 +38,10 @@ public Analyzer createAnalyzer()
{
return new LithuanianAnalyzer();
}

@Override
public String description()
{
return "Lithuanian analyzer with stemming and stop word filtering.";
}
}
Expand Up @@ -38,4 +38,10 @@ public Analyzer createAnalyzer()
{
return new NorwegianAnalyzer();
}

@Override
public String description()
{
return "Norwegian analyzer with stemming and stop word filtering.";
}
}

0 comments on commit 5f1bef7

Please sign in to comment.