- [Lucene]Nutch/Lucene的存取机制与结构分析
- [Lucene]Hibernate Search牛刀小试
- [Lucene]lucene2_0创建、检索和删除功能的完
- [Lucene]Lucene+hibernate+spring配置心得
- [Lucene]lucene 学习
- [Lucene]Lucene 安装
- [Lucene]LUCENE中文使用先锋和前辈
- [Lucene]Nabble
- [Lucene]LUCENE IN ACTION中文版-第七章(1)
- [Lucene]A quick (less certain) note on usi
- [Lucene]Lucene In-Memory Text Search Examp
- [Lucene]lucene-Class MemoryIndex
- [Lucene]基于LUCENE的英汉双语信息检索研究
- [Lucene] Lucene In Action中文版-第四章(II)
- [Lucene]Lucene In Action中文版-第四章(1)-A
- [Lucene]lucene Class ChineseAnalyzer
- [Lucene]LUCENE module
- [Lucene]lucene结构中文说明(一)
- [Lucene]New Search Tool on iXtenso
- [Lucene]Nutch/Lucene的存取机制与结构分析
- [Lucene]lucene.net的一些基本使用方法和概念
- [Lucene]Lucene搜索引擎API的主要类介绍
- [Lucene]Hibernate Search牛刀小试
- [Lucene]广州太博互动诚聘精英
- [Lucene]LUCEN:如何索引PDF格式文件
- [Lucene] Full-time opportunity in Paris, F
- [Lucene]Lucene索引查询分页实例
- [Lucene] 使用Lucene进行全文检索
- [Lucene]lucene2_0创建、检索和删除功能的完
- [Lucene]Lucene+hibernate+spring配置心得
- [Lucene]lucene Class ChineseAnalyzer
- [Lucene]LUCENE module
- [Lucene]lucene结构中文说明(一)
- [Lucene]New Search Tool on iXtenso
- [Lucene]Nutch/Lucene的存取机制与结构分析
- [Lucene]lucene.net的一些基本使用方法和概念
- [Lucene]Lucene搜索引擎API的主要类介绍
- [Lucene]Hibernate Search牛刀小试
- [Lucene]广州太博互动诚聘精英
- [Lucene]LUCEN:如何索引PDF格式文件
- [Lucene] Full-time opportunity in Paris, F
- [Lucene]Lucene索引查询分页实例
- [Lucene] 使用Lucene进行全文检索
- [Lucene]lucene2_0创建、检索和删除功能的完
- [Lucene]Lucene+hibernate+spring配置心得
- Google广告位置
- Google AD
首先来谈下lucene
项目的service端运用spring+hibernate开发。其间用到lucene做全文检索。版本为2.2,分词用的是JE-Analysis1.5.1.MMAnalyzer.建立索引用到队列。
我们先在blogservice里初始化索引路径,其实现是在spring配置文件里设置:
<bean id="blogService" class="cn.shell.service.BlogService"
parent="baseService">
<property name="indexPathRoot"
value="${webapp.root}WEB-INF/index/blog/">
</property>
</bean>
项目中主要是要求提高性能,所以采用队列来创建索引。List waitToIndexList=new LinkedList();
创建索引部分:
IndexWriter indexWriter;
IndexSearcher indexSearcher;
创建新线程:Thread indexThread=new Thread(this);
实例分词: MMAnalyzer analyzer=new MMAnalyzer();
初始化部分:
public void init(){
File rp = new File(indexPathRoot);
if (!rp.exists()) {
rp.mkdirs();
}
File segments = new File(indexPathRoot + File.separator
+ "segments.gen");
boolean bCreate = true;
if (segments.exists()) {
bCreate = false;
}
try {
indexWriter = new IndexWriter(indexPathRoot, analyzer, bCreate);
indexSearcher = new IndexSearcher(indexPathRoot);
} catch (Exception e) {
logger.error("init indexWriter fail", e);
}
indexThread.start(); //启动线程
}
public void run(){
while (!indexThread.isInterrupted()) {
if (!waitToIndexList.isEmpty()) {
Blog blog = (Blog) waitToIndexList.remove(0);
Document doc = new Document();
doc.add(new Field("blogID", blog.getBlogID(), Field.Store.YES,
Field.Index.UN_TOKENIZED));
doc.add(new Field("title", blog.getTitle(), Field.Store.YES,
Field.Index.TOKENIZED));
doc.add(new Field("content", blog.getContent(),
Field.Store.YES, Field.Index.TOKENIZED));
doc.add(new Field("author", blog.getClientUser().getNickName(),
Field.Store.YES, Field.Index.TOKENIZED));
try {
indexWriter.addDocument(doc);
indexWriter.flush();
indexWriter.optimize();
} catch (Exception e) {
logger.error("create index error", e);
}
}
try {
Thread.sleep(50);
} catch (Exception e) {
logger.error(e);
}
}}
最新评论:
