解决包升级的冲突,升级到 8.0.0 版本

This commit is contained in:
YuCheng Hu 2025-04-25 15:42:30 -04:00
parent f50bccce9d
commit 8cba34008b
Signed by: honeymoose
GPG Key ID: D74AE0B33A8002EC
3 changed files with 6 additions and 6 deletions

View File

@ -33,7 +33,7 @@
</dependencies> </dependencies>
<properties> <properties>
<lucene.version>7.7.3</lucene.version> <lucene.version>8.0.0</lucene.version>
</properties> </properties>
</project> </project>

View File

@ -4,10 +4,10 @@ import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.LowerCaseFilter; import org.apache.lucene.analysis.LowerCaseFilter;
import org.apache.lucene.analysis.StopFilter; import org.apache.lucene.analysis.StopFilter;
import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.en.EnglishAnalyzer;
import org.apache.lucene.analysis.en.PorterStemFilter; import org.apache.lucene.analysis.en.PorterStemFilter;
import org.apache.lucene.analysis.miscellaneous.CapitalizationFilter; import org.apache.lucene.analysis.miscellaneous.CapitalizationFilter;
import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.analysis.standard.ClassicFilter;
import org.apache.lucene.analysis.standard.StandardFilter;
import org.apache.lucene.analysis.standard.StandardTokenizer; import org.apache.lucene.analysis.standard.StandardTokenizer;
public class MyCustomAnalyzer extends Analyzer{ public class MyCustomAnalyzer extends Analyzer{
@ -15,9 +15,9 @@ public class MyCustomAnalyzer extends Analyzer{
@Override @Override
protected TokenStreamComponents createComponents(String fieldName) { protected TokenStreamComponents createComponents(String fieldName) {
final StandardTokenizer src = new StandardTokenizer(); final StandardTokenizer src = new StandardTokenizer();
TokenStream result = new StandardFilter(src); TokenStream result = new ClassicFilter(src);
result = new LowerCaseFilter(result); result = new LowerCaseFilter(result);
result = new StopFilter(result, StandardAnalyzer.STOP_WORDS_SET); result = new StopFilter(result, EnglishAnalyzer.ENGLISH_STOP_WORDS_SET);
result = new PorterStemFilter(result); result = new PorterStemFilter(result);
result = new CapitalizationFilter(result); result = new CapitalizationFilter(result);
return new TokenStreamComponents(src, result); return new TokenStreamComponents(src, result);

View File

@ -42,7 +42,7 @@ public class LuceneAnalyzerIntegrationTest {
@Test @Test
public void whenUseStopAnalyzer_thenAnalyzed() throws IOException { public void whenUseStopAnalyzer_thenAnalyzed() throws IOException {
List<String> result = analyze(SAMPLE_TEXT, new StopAnalyzer()); List<String> result = analyze(SAMPLE_TEXT, new StopAnalyzer(EnglishAnalyzer.ENGLISH_STOP_WORDS_SET));
assertThat(result, contains("baeldung", "com", "lucene", "analyzers", "test")); assertThat(result, contains("baeldung", "com", "lucene", "analyzers", "test"));
} }