Doua Beri Doua Beri - 12 days ago 10
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 :

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

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


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.