org.apache.lucene.analysis.core

## Class StopAnalyzer

- java.lang.Object
- - org.apache.lucene.analysis.Analyzer
  - - org.apache.lucene.analysis.StopwordAnalyzerBase
    - - org.apache.lucene.analysis.core.StopAnalyzer

- All Implemented Interfaces:
    Closeable, AutoCloseable

      public final class StopAnalyzer
      extends StopwordAnalyzerBase

  Filters `LetterTokenizer` with `LowerCaseFilter` and `StopFilter`.
  Since:
    3.1

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.apache.lucene.analysis.Analyzer

      `Analyzer.ReuseStrategy, Analyzer.TokenStreamComponents`

  - ### Field Summary

    - ### Fields inherited from class org.apache.lucene.analysis.StopwordAnalyzerBase

      `stopwords`

    - ### Fields inherited from class org.apache.lucene.analysis.Analyzer

      `GLOBAL_REUSE_STRATEGY, PER_FIELD_REUSE_STRATEGY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `StopAnalyzer(CharArraySet stopWords)` Builds an analyzer with the stop words from the given set.
    `StopAnalyzer(Path stopwordsFile)` Builds an analyzer with the stop words from the given path.
    `StopAnalyzer(Reader stopwords)` Builds an analyzer with the stop words from the given reader.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected Analyzer.TokenStreamComponents` | `createComponents(String fieldName)` Creates `Analyzer.TokenStreamComponents` used to tokenize all the text in the provided `Reader`.
    `protected TokenStream` | `normalize(String fieldName, TokenStream in)`

    - ### Methods inherited from class org.apache.lucene.analysis.StopwordAnalyzerBase

      `getStopwordSet, loadStopwordSet, loadStopwordSet, loadStopwordSet`

    - ### Methods inherited from class org.apache.lucene.analysis.Analyzer

      `attributeFactory, close, getOffsetGap, getPositionIncrementGap, getReuseStrategy, getVersion, initReader, initReaderForNormalization, normalize, setVersion, tokenStream, tokenStream`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### StopAnalyzer

          public StopAnalyzer(CharArraySet stopWords)

      Builds an analyzer with the stop words from the given set.
      Parameters:
        `stopWords` - Set of stop words

    - #### StopAnalyzer

          public StopAnalyzer(Path stopwordsFile)
                       throws IOException

      Builds an analyzer with the stop words from the given path.
      Parameters:
        `stopwordsFile` - File to load stop words from
      Throws:
        `IOException`
      See Also:
        `WordlistLoader.getWordSet(Reader)`

    - #### StopAnalyzer

          public StopAnalyzer(Reader stopwords)
                       throws IOException

      Builds an analyzer with the stop words from the given reader.
      Parameters:
        `stopwords` - Reader to load stop words from
      Throws:
        `IOException`
      See Also:
        `WordlistLoader.getWordSet(Reader)`

  - ### Method Detail

    - #### createComponents

          protected Analyzer.TokenStreamComponents createComponents(String fieldName)

      Creates `Analyzer.TokenStreamComponents` used to tokenize all the text in the provided `Reader`.
      Specified by:
        `createComponents` in class `Analyzer`
      Returns:
        `Analyzer.TokenStreamComponents` built from a `LetterTokenizer` filtered with `StopFilter`

    - #### normalize

          protected TokenStream normalize(String fieldName,
                                          TokenStream in)

      Overrides:
        `normalize` in class `Analyzer`

Copyright © 2000-2024 Apache Software Foundation. All Rights Reserved.