Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to instruct StandardAnalyzer in Lucene to not to remove stop words?

Tags:

lucene

Simple question : How to make Lucene's StandardAnalyzer not to remove stop words when analyzing my sentence ?

like image 348
Shrinath Avatar asked Feb 24 '11 09:02

Shrinath


3 Answers

The answer is version-dependent. For Lucene 3.0.3 (current), you need to construct the StandardAnalyzer with an empty set of stop words, using something like this:

Analyzer ana = new StandardAnalyzer(LUCENE_30, Collections.emptySet());
like image 182
Yuval F Avatar answered Nov 13 '22 18:11

Yuval F


Update: the answer is version-dependent. For Lucene 4.0, use:

Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_40, CharArraySet.EMPTY_SET);

Note that the StandardAnalyzer is not in the lucene-core jar, but in lucene-analyzers-common-4.0.0.jar

like image 7
Alphaaa Avatar answered Nov 13 '22 19:11

Alphaaa


For Lucene 6.0.0, use

StandardAnalyzer analyzer = StandardAnalyzer(CharArraySet.EMPTY_SET);
like image 2
Felix Bohnacker Avatar answered Nov 13 '22 19:11

Felix Bohnacker