Shrinath
Shrinath

Reputation: 8118

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

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

Upvotes: 10

Views: 8083

Answers (3)

Felix Bohnacker
Felix Bohnacker

Reputation: 47

For Lucene 6.0.0, use

StandardAnalyzer analyzer = StandardAnalyzer(CharArraySet.EMPTY_SET);

Upvotes: 3

Alphaaa
Alphaaa

Reputation: 4316

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

Upvotes: 7

Yuval F
Yuval F

Reputation: 20621

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());

Upvotes: 12

Related Questions