![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Lucene
吴帝永
这个作者很懒,什么都没留下…
展开
-
lucene4.0入门实例
先要导入lucene包:lucene-core-4.0.0.jarlucene-analyzers-common-4.0.0.jar这里使用Lucene提供的默认分词器,不支持中文分词创建索引的代码如下:import java.io.File;import org.apache.lucene.analysis.Analyzer;import org.apache原创 2015-09-08 13:38:20 · 438 阅读 · 0 评论 -
中文检索(分词、同义词、权重)
1、首先导入Lucene相关包:lucene-analyzers-common-4.7.1.jarlucene-core-4.7.1.jarlucene-facet-4.7.1.jarlucene-highlighter-4.7.1.jarlucene-queries-4.7.1.jarlucene-queryparser-4.7.1.jar2、然后把分词源码I原创 2015-09-08 13:35:19 · 6827 阅读 · 0 评论 -
避免每次检索都使用DirectoryReader.open()
反复使用DirectoryReader.open()会产生很大开销,所以应尽可能复用之前打开的IndexReader,可以使用单例模式,但要注意,当索引被修改了,之前打开的indexReader也不会更新,如下面的单例模式:publicclass TestIndexReader { privatestatic Directory directory = null;原创 2015-09-08 13:36:48 · 1917 阅读 · 0 评论 -
使用commit及时更新索引
当修改、删除或插入数据的时候,如果短时间内没有关闭IndexWriter,可以使用commit来提交当前的更新,这样的话indexReader马上可以察觉到索引被更新。修改:indexWriter.updateDocument(new Term("id","1"), document);indexWriter.commit();把id等于1的那条数据修改成document这条数据,原创 2015-09-08 13:37:11 · 458 阅读 · 0 评论