Skip to content

Commit e928c2a

Browse files
committed
Merge pull request '添加 lucene 项目' (#44) from ethereum into main
Reviewed-on: https://src.isharkfly.com/iSharkFly-Docs/java-tutorials/pulls/44 升级版本的讨论:https://www.isharkfly.com/t/lucene-8-0-0/15924
2 parents b25c99d + 8cba340 commit e928c2a

File tree

6 files changed

+15
-10
lines changed

6 files changed

+15
-10
lines changed

.idea/compiler.xml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/encodings.xml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lucene/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
<description>An Apache Lucene demo application</description>
1010

1111
<parent>
12-
<groupId>com.baeldung</groupId>
12+
<groupId>com.ossez</groupId>
1313
<artifactId>parent-modules</artifactId>
14-
<version>1.0.0-SNAPSHOT</version>
14+
<version>0.0.2-SNAPSHOT</version>
1515
</parent>
1616

1717
<dependencies>
@@ -33,7 +33,7 @@
3333
</dependencies>
3434

3535
<properties>
36-
<lucene.version>7.4.0</lucene.version>
36+
<lucene.version>8.0.0</lucene.version>
3737
</properties>
3838

3939
</project>

lucene/src/main/java/com/baeldung/lucene/MyCustomAnalyzer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44
import org.apache.lucene.analysis.LowerCaseFilter;
55
import org.apache.lucene.analysis.StopFilter;
66
import org.apache.lucene.analysis.TokenStream;
7+
import org.apache.lucene.analysis.en.EnglishAnalyzer;
78
import org.apache.lucene.analysis.en.PorterStemFilter;
89
import org.apache.lucene.analysis.miscellaneous.CapitalizationFilter;
9-
import org.apache.lucene.analysis.standard.StandardAnalyzer;
10-
import org.apache.lucene.analysis.standard.StandardFilter;
10+
import org.apache.lucene.analysis.standard.ClassicFilter;
1111
import org.apache.lucene.analysis.standard.StandardTokenizer;
1212

1313
public class MyCustomAnalyzer extends Analyzer{
1414

1515
@Override
1616
protected TokenStreamComponents createComponents(String fieldName) {
1717
final StandardTokenizer src = new StandardTokenizer();
18-
TokenStream result = new StandardFilter(src);
18+
TokenStream result = new ClassicFilter(src);
1919
result = new LowerCaseFilter(result);
20-
result = new StopFilter(result, StandardAnalyzer.STOP_WORDS_SET);
20+
result = new StopFilter(result, EnglishAnalyzer.ENGLISH_STOP_WORDS_SET);
2121
result = new PorterStemFilter(result);
2222
result = new CapitalizationFilter(result);
2323
return new TokenStreamComponents(src, result);

lucene/src/test/java/com/baeldung/lucene/LuceneAnalyzerIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public void whenUseStandardAnalyzer_thenAnalyzed() throws IOException {
4242

4343
@Test
4444
public void whenUseStopAnalyzer_thenAnalyzed() throws IOException {
45-
List<String> result = analyze(SAMPLE_TEXT, new StopAnalyzer());
45+
List<String> result = analyze(SAMPLE_TEXT, new StopAnalyzer(EnglishAnalyzer.ENGLISH_STOP_WORDS_SET));
4646

4747
assertThat(result, contains("baeldung", "com", "lucene", "analyzers", "test"));
4848
}

pom.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,19 @@
4242
<module>apache</module>
4343
<module>core-java-modules</module>
4444
<module>ethereum</module>
45+
4546
<module>image-compressing</module>
4647
<module>image-processing</module>
4748
<module>libraries-jackson</module>
49+
<module>lucene</module>
4850
<!-- <module>jackson-simple</module>-->
4951
<!-- <module>parent-java</module>-->
5052
<module>parent-boot-2</module>
5153
<module>parent-boot-3</module>
5254
<module>persistence-modules</module>
5355
<module>testing-modules</module>
5456
<module>toolkits</module>
55-
<!-- <module>xml</module>-->
57+
<module>xml</module>
5658
</modules>
5759

5860
<properties>

0 commit comments

Comments
 (0)