You can add add additional stop words to a copy of the standard English word stop word or just add another StopFilter. How:
TokenStream tokenStream = new StandardTokenizer(Version.LUCENE_36, new StringReader(string)); CharArraySet stopSet = CharArraySet.copy(Version.LUCENE_36, StandardAnalyzer.STOP_WORD_SET); stopSet.add("add"); stopSet.add("your"); stopSet.add("stop"); stopSet.add("words"); tokenStream = new StopFilter(Version.LUCENE_36, tokenStream, stopSet);
or
TokenStream tokenStream = new StandardTokenizer(Version.LUCENE_36, new StringReader(string)); tokenStream = new StopFilter(Version.LUCENE_36, tokenStream, StandardAnalyzer.STOP_WORDS_SET); List<String> stopWords =
If you are trying to create your own analyzer, you may be better served with the following template, similar to the example in the analyzer documentation .
source share