1.最近研究了一下lucene全文检索,做了一个小demo,检索txt文件,项目使用maven,首先引入<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers</artifactId>
<version>3.6.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
<version>3.6.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
2.在e盘test目录建立txt文件,内容为 中华人民共和国,建立索引类TextFileIndexer
3.建立查询类TestQuery,查询结果找到:3 个结果!
----------------分割线----------------------
path:e:\test\1.txt
socre:0.2518424
----------------分割线----------------------
path:e:\test\复件 (2) 1.txt
socre:0.2518424
----------------分割线----------------------
path:e:\test\复件 1.txt
socre:0.2518424
java类内容见附件
lucene3.6.1学习
猜你喜欢
转载自lijunlong.iteye.com/blog/1667037
今日推荐
周排行