jruby/docs BETA
Navigation
org.apache.lucene.analysis.standard 4
C StandardAnalyzer
C StandardTokenizer
C StandardTokenizerFactory
C StandardTokenizerImpl
StandardAnalyzer — members 6+
F DEFAULT_MAX_TOKEN_LENGTH() int
C new(stop_words)
C new()
C new(stopwords)
M max_token_length() int
C max_token_length=(length)
from Analyzer
F GLOBAL_REUSE_STRATEGY ReuseStrategy
F PER_FIELD_REUSE_STRATEGY ReuseStrategy
C close()
M get_offset_gap(field_name) int
M get_position_increment_gap(field_name) int
M normalize(field_name, text) BytesRef
M reuse_strategy() ReuseStrategy
M token_stream(field_name, reader) TokenStream
M token_stream(field_name, text) TokenStream
from StopwordAnalyzerBase
M stopword_set() CharArraySet

org.apache.lucene.analysis.standard.StandardAnalyzer

class final extends StopwordAnalyzerBase 6 members

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

Constants

constanttypenote
DEFAULT_MAX_TOKEN_LENGTH int Default maximum allowed token length

Constructors

new

new ( CharArraySet stop_words )
Java: <init>(org.apache.lucene.analysis.CharArraySet stopWords)

Builds an analyzer with the given stop words.

nametypedescription
stop_wordsorg.apache.lucene.analysis.CharArraySetstop words

new

new ( )
Java: <init>()

Builds an analyzer with no stop words.

new

new ( Reader stopwords )
Java: <init>(java.io.Reader stopwords)

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

nametypedescription
stopwordsjava.io.ReaderReader to read stop words from

Instance Methods

max_token_length

int max_token_length ( )
Java: getMaxTokenLength() · also: get_max_token_length

Returns the current maximum token length

max_token_length=

max_token_length= ( int length )
Java: setMaxTokenLength(int length) · also: set_max_token_length

Set the max allowed token length. Tokens larger than this will be chopped up at this token length and emitted as multiple tokens. If you need to skip such large tokens, you could increase this max length, and then use LengthFilter to remove long tokens. The default is StandardAnalyzer#DEFAULT_MAX_TOKEN_LENGTH.

Inherited

from Analyzer

fieldtypenote
GLOBAL_REUSE_STRATEGY Analyzer.ReuseStrategy A predefined ReuseStrategy that reuses the same components for every field.
PER_FIELD_REUSE_STRATEGY Analyzer.ReuseStrategy A predefined ReuseStrategy that reuses components per-field by maintaining a Map of TokenStreamComponent per field name.

close

close ( )
Java: close()

Frees persistent resources used by this Analyzer

get_offset_gap

int get_offset_gap ( String field_name )
Java: getOffsetGap(String fieldName)

Just like #getPositionIncrementGap, except for Token offsets instead. By default this returns 1. This method is only called if the field produced at least one token for indexing.

nametypedescription
field_nameStringthe field just indexed

Returns: offset gap, added to the next token emitted from #tokenStream(String,Reader). This value must be >= 0.

get_position_increment_gap

int get_position_increment_gap ( String field_name )
Java: getPositionIncrementGap(String fieldName)

Invoked before indexing a IndexableField instance if terms have already been added to that field. This allows custom analyzers to place an automatic position increment gap between IndexbleField instances using the same field name. The default value position increment gap is 0. With a 0 position increment gap and the typical default token position increment of 1, all terms in a field, including across IndexableField instances, are in successive positions, allowing exact PhraseQuery matches, for instance, across IndexableField instance boundaries.

nametypedescription
field_nameStringIndexableField name being indexed.

Returns: position increment gap, added to the next token emitted from #tokenStream(String,Reader). This value must be >= 0.

normalize

BytesRef normalize ( String field_name, String text )
Java: normalize(String fieldName, String text)

Normalize a string down to the representation that it would have in the index.

This is typically used by query parsers in order to generate a query on a given term, without tokenizing or stemming, which are undesirable if the string to analyze is a partial word (eg. in case of a wildcard or fuzzy query).

This method uses #initReaderForNormalization(String, Reader) in order to apply necessary character-level normalization and then #normalize(String, TokenStream) in order to apply the normalizing token filters.

reuse_strategy

Analyzer.ReuseStrategy reuse_strategy ( )
Java: getReuseStrategy() · also: get_reuse_strategy

Returns the used ReuseStrategy.

token_stream

TokenStream token_stream ( String field_name, Reader reader )
Java: tokenStream(String fieldName, java.io.Reader reader)

Returns a TokenStream suitable for fieldName, tokenizing the contents of reader.

This method uses #createComponents(String) to obtain an instance of TokenStreamComponents. It returns the sink of the components and stores the components internally. Subsequent calls to this method will reuse the previously stored components after resetting them through TokenStreamComponents#setReader(Reader).

NOTE: After calling this method, the consumer must follow the workflow described in TokenStream to properly consume its contents. See the Analysis package documentation for some examples demonstrating this.

NOTE: If your data is available as a String, use #tokenStream(String, String) which reuses a StringReader-like instance internally.

nametypedescription
field_nameStringthe name of the field the created TokenStream is used for
readerjava.io.Readerthe reader the streams source reads from

Returns: TokenStream for iterating the analyzed content of reader

Throws

AlreadyClosedException if the Analyzer is closed.

token_stream

TokenStream token_stream ( String field_name, String text )
Java: tokenStream(String fieldName, String text)

Returns a TokenStream suitable for fieldName, tokenizing the contents of text.

This method uses #createComponents(String) to obtain an instance of TokenStreamComponents. It returns the sink of the components and stores the components internally. Subsequent calls to this method will reuse the previously stored components after resetting them through TokenStreamComponents#setReader(Reader).

NOTE: After calling this method, the consumer must follow the workflow described in TokenStream to properly consume its contents. See the Analysis package documentation for some examples demonstrating this.

nametypedescription
field_nameStringthe name of the field the created TokenStream is used for
textStringthe String the streams source reads from

Returns: TokenStream for iterating the analyzed content of reader

Throws

AlreadyClosedException if the Analyzer is closed.

from StopwordAnalyzerBase

stopword_set

CharArraySet stopword_set ( )
Java: getStopwordSet() · also: get_stopword_set

Returns the analyzer's stopword set or an empty set if the analyzer has no stopwords

Returns: the analyzer's stopword set or an empty set if the analyzer has no stopwords

this work for additional information regarding copyright ownership.