Skip to content

Commit

Permalink
升级lucene,从4.10.4到5.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ysc committed May 6, 2015
1 parent 63652b8 commit 89947eb
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 2 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,9 @@

2、利用word分析器切分文本
TokenStream tokenStream = analyzer.tokenStream("text", "杨尚川是APDPlat应用级产品开发平台的作者");
//准备消费
tokenStream.reset();
//开始消费
while(tokenStream.incrementToken()){
//词
CharTermAttribute charTermAttribute = tokenStream.getAttribute(CharTermAttribute.class);
Expand All @@ -366,10 +369,12 @@
LOGGER.info("Synonym:"+synonymAttribute.toString());
LOGGER.info("Antonym:"+antonymAttribute.toString());
}
//消费完毕
tokenStream.close();

3、利用word分析器建立Lucene索引
Directory directory = new RAMDirectory();
IndexWriterConfig config = new IndexWriterConfig(Version.LATEST, analyzer);
IndexWriterConfig config = new IndexWriterConfig(analyzer);
IndexWriter indexWriter = new IndexWriter(directory, config);

4、利用word分析器查询Lucene索引
Expand Down
74 changes: 73 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
<randomizedtesting.version>2.1.11</randomizedtesting.version>
<slf4j-api.version>1.6.4</slf4j-api.version>
<logback-classic.version>0.9.28</logback-classic.version>
<lucene.version>4.10.4</lucene.version>
<lucene.version>5.1.0</lucene.version>
<elasticsearch.version>1.5.1</elasticsearch.version>
<jedis.version>2.5.1</jedis.version>
<pinyin4j.version>2.5.0</pinyin4j.version>
Expand Down Expand Up @@ -198,12 +198,54 @@
<version>${lucene.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-backward-codecs</artifactId>
<version>${lucene.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-suggest</artifactId>
<version>${lucene.version}</version>
<optional>true</optional>
</dependency>
<!-- 中文分词elasticsearch插件依赖库 -->
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>${elasticsearch.version}</version>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-memory</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-highlighter</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-suggest</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-misc</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-join</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-grouping</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-spatial</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- elasticsearch测试依赖 -->
<dependency>
Expand All @@ -212,6 +254,36 @@
<version>${elasticsearch.version}</version>
<type>test-jar</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-memory</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-highlighter</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-suggest</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-misc</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-join</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-grouping</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-spatial</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- redis客户端库 -->
<dependency>
Expand Down

0 comments on commit 89947eb

Please sign in to comment.