org.compass.annotations
Annotation Type SearchAnalyzer


@Target(value=PACKAGE)
@Retention(value=RUNTIME)
public @interface SearchAnalyzer

Configure Analyzer to be used within Compass. Set on package definition (package-info.java).

The Analyzer is registed under a lookup name (name()), which can then be reference in the different mapping definitions.

Allows for simple configuration of all analyzers that come with Compass using type(). If the type() is set to AnalyzerType.Snowball, the snowballType() can be used to further configure the snowball analyzer. If a custom converter needs to be registered with Compass, the AnalyzerType.CustomAnalyzer needs to be set on type(), and the analyzerClass() needs to be configured with the class that implements it.

A set of stop words can be added/replace the stop words the internal analyzers are configured with. The stop words will be added if the addStopWords() is set to true.

Further settings can be set for a specialized analyzer using settings(). If the specialized Analyzer requires settings to be injected, it needs to implement the CompassConfigurable interface.

To replace Compas default analyzer, the name() should be set LuceneEnvironment.Analyzer.DEFAULT_GROUP.

To replace Compass search analyzer (which defaults to the default analyzer if not set), the name() should be set to LuceneEnvironment.Analyzer.SEARCH_GROUP.

Multiple analyzers can be defined using the SearchAnalyzers annotation.

Note, that Analyzers can also be conifugred using Compass configuration mechanism.

Author:
kimchy

Required Element Summary
 String name
          The name the analyzer will be registered under.
 AnalyzerType type
          The type of the analyzer.
 
Optional Element Summary
 boolean addStopWords
          Add the set of stopWords() to the default set of stop words if set to true.
 Class<? extends Analyzer> analyzerClass
          The custom Analyzer implementation.
 String[] filters
          A set of LuceneAnalyzerTokenFilterProviders lookup names to be used with the Analyzer.
 SearchSetting[] settings
          Futher settings for a custom Analyzer implementation.
 SnowballType snowballType
          If the type() is set to AnalyzerType.Snowball, controls the snowball analyzer type.
 String[] stopWords
          A set of stop words that will be added/replace the stop words that comes with Compass intenral analyzers.
 

Element Detail

name

public abstract String name
The name the analyzer will be registered under.


type

public abstract AnalyzerType type
The type of the analyzer. For custom Analyzer implementation the AnalyzerType.CustomAnalyzer should be set, and the analyzerClass() should have the custom Analyzer class set.

snowballType

public abstract SnowballType snowballType
If the type() is set to AnalyzerType.Snowball, controls the snowball analyzer type.

Default:
Porter

analyzerClass

public abstract Class<? extends Analyzer> analyzerClass
The custom Analyzer implementation. Used when the type() is set to AnalyzerType.CustomAnalyzer.

Default:
org.apache.lucene.analysis.Analyzer.class

filters

public abstract String[] filters
A set of LuceneAnalyzerTokenFilterProviders lookup names to be used with the Analyzer.

Filters can be configured using SearchAnalyzerFilter or using Compass configuration.

Default:
{}

stopWords

public abstract String[] stopWords
A set of stop words that will be added/replace the stop words that comes with Compass intenral analyzers.

Only applies when using one of Compass internal analyzer types, and not the AnalyzerType.CustomAnalyzer.

Default:
{}

addStopWords

public abstract boolean addStopWords
Add the set of stopWords() to the default set of stop words if set to true. Replaces them if set to false.

Only applies when using one of Compass internal analyzer types, and not the AnalyzerType.CustomAnalyzer.

Default:
true

settings

public abstract SearchSetting[] settings
Futher settings for a custom Analyzer implementation.

Default:
{}


Copyright (c) 2004-2008 The Compass Project.