public class

StandardAnalyzer

extends Analyzer
java.lang.Object
   ↳ org.apache.lucene.analysis.Analyzer
     ↳ org.apache.lucene.analysis.standard.StandardAnalyzer

Class Overview

Filters StandardTokenizer with StandardFilter, LowerCaseFilter and StopFilter, using a list of English stop words.

You must specify the required Version compatibility when creating StandardAnalyzer:

  • As of 2.9, StopFilter preserves position increments
  • As of 2.4, Tokens incorrectly identified as acronyms are corrected (see LUCENE-1608

Summary

Constants
int DEFAULT_MAX_TOKEN_LENGTH Default maximum allowed token length
Fields
public static final Set<?> STOP_WORDS_SET An unmodifiable set containing some common English words that are usually not useful for searching.
[Expand]
Inherited Fields
From class org.apache.lucene.analysis.Analyzer
Public Constructors
StandardAnalyzer(Version matchVersion)
Builds an analyzer with the default stop words (STOP_WORDS_SET).
StandardAnalyzer(Version matchVersion, Set<?> stopWords)
Builds an analyzer with the given stop words.
StandardAnalyzer(Version matchVersion, File stopwords)
Builds an analyzer with the stop words from the given file.
StandardAnalyzer(Version matchVersion, Reader stopwords)
Builds an analyzer with the stop words from the given reader.
Public Methods
int getMaxTokenLength()
TokenStream reusableTokenStream(String fieldName, Reader reader)
Creates a TokenStream that is allowed to be re-used from the previous time that the same thread called this method.
void setMaxTokenLength(int length)
Set maximum allowed token length.
TokenStream tokenStream(String fieldName, Reader reader)
Constructs a StandardTokenizer filtered by a StandardFilter, a LowerCaseFilter and a StopFilter.
[Expand]
Inherited Methods
From class org.apache.lucene.analysis.Analyzer
From class java.lang.Object
From interface java.io.Closeable

Constants

public static final int DEFAULT_MAX_TOKEN_LENGTH

Default maximum allowed token length

Constant Value: 255 (0x000000ff)

Fields

public static final Set<?> STOP_WORDS_SET

An unmodifiable set containing some common English words that are usually not useful for searching.

Public Constructors

public StandardAnalyzer (Version matchVersion)

Builds an analyzer with the default stop words (STOP_WORDS_SET).

Parameters
matchVersion Lucene version to match See above

public StandardAnalyzer (Version matchVersion, Set<?> stopWords)

Builds an analyzer with the given stop words.

Parameters
matchVersion Lucene version to match See above
stopWords stop words

public StandardAnalyzer (Version matchVersion, File stopwords)

Builds an analyzer with the stop words from the given file.

Parameters
matchVersion Lucene version to match See above
stopwords File to read stop words from
Throws
IOException
See Also

public StandardAnalyzer (Version matchVersion, Reader stopwords)

Builds an analyzer with the stop words from the given reader.

Parameters
matchVersion Lucene version to match See above
stopwords Reader to read stop words from
Throws
IOException

Public Methods

public int getMaxTokenLength ()

public TokenStream reusableTokenStream (String fieldName, Reader reader)

Creates a TokenStream that is allowed to be re-used from the previous time that the same thread called this method. Callers that do not need to use more than one TokenStream at the same time from this analyzer should use this method for better performance.

Throws
IOException

public void setMaxTokenLength (int length)

Set maximum allowed token length. If a token is seen that exceeds this length then it is discarded. This setting only takes effect the next time tokenStream or reusableTokenStream is called.

public TokenStream tokenStream (String fieldName, Reader reader)

Constructs a StandardTokenizer filtered by a StandardFilter, a LowerCaseFilter and a StopFilter.