Doua Beri Doua Beri - 1 month ago 36
Java Question

Apache Lucene 6.2 StandardAnalyzer version

I'm new to Apache Lucene. I'm using currently the latest version: 6.2.1

Based on their official documentation : http://lucene.apache.org/core/6_2_1/core/org/apache/lucene/analysis/package-summary.html

Version matchVersion = Version.LUCENE_6_2_1;
Analyzer analyzer = new StandardAnalyzer(matchVersion);


doesn't work. It tells me there is no StandardAnalyzer constructor that receives a Version parameter;

I did something like this

Version matchVersion = Version.LUCENE_6_2_1;
Analyzer analyzer = new StandardAnalyzer();
analyzer.setVersion(matchVersion);


Is this the correct way to do and the documentation is older? Or I need to add some more extra libraries besides lucene-core?

Answer

Yes, the Version argument was removed in version 5.0. Setting it using setVersion would be correct. However, it should be noted that setting the version won't actually do anything. StandardAnalyzer doesn't use it.

If you want to use the old StandardAnalyzer logic (used in version 3.1 and before), you should use ClassicAnalyzer instead.