解决包升级的冲突,升级到 8.0.0 版本
This commit is contained in:
parent
f50bccce9d
commit
8cba34008b
@ -33,7 +33,7 @@
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<lucene.version>7.7.3</lucene.version>
|
||||
<lucene.version>8.0.0</lucene.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -4,10 +4,10 @@ import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.analysis.LowerCaseFilter;
|
||||
import org.apache.lucene.analysis.StopFilter;
|
||||
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.miscellaneous.CapitalizationFilter;
|
||||
import org.apache.lucene.analysis.standard.StandardAnalyzer;
|
||||
import org.apache.lucene.analysis.standard.StandardFilter;
|
||||
import org.apache.lucene.analysis.standard.ClassicFilter;
|
||||
import org.apache.lucene.analysis.standard.StandardTokenizer;
|
||||
|
||||
public class MyCustomAnalyzer extends Analyzer{
|
||||
@ -15,9 +15,9 @@ public class MyCustomAnalyzer extends Analyzer{
|
||||
@Override
|
||||
protected TokenStreamComponents createComponents(String fieldName) {
|
||||
final StandardTokenizer src = new StandardTokenizer();
|
||||
TokenStream result = new StandardFilter(src);
|
||||
TokenStream result = new ClassicFilter(src);
|
||||
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 CapitalizationFilter(result);
|
||||
return new TokenStreamComponents(src, result);
|
||||
|
@ -42,7 +42,7 @@ public class LuceneAnalyzerIntegrationTest {
|
||||
|
||||
@Test
|
||||
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"));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user