Lucene 4.0
关于4.0的Update Index ,Create Index
/*
* Create Index
*/
public static void createIndex() throws IOException{ try {
Directory directory=FSDirectory.open(new File(indexPath));
IndexWriterConfig config=new IndexWriterConfig(Version.LUCENE_44,analyzer);
config.setOpenMode(OpenMode.CREATE_OR_APPEND);
IndexWriter writer=new IndexWriter(directory,config);
Document document=new Document();
document.add(new org.apache.lucene.document.TextField("content",strBuilder.toString(),Store.YES));
document.add(new org.apache.lucene.document.StringField("path", indexPath, Store.YES));
document.add(new org.apache.lucene.document.StringField("name", "lucene", Store.YES));
writer.addDocument(document);
writer.close(); } catch (Exception e) {
// TODO: handle exception
System.out.println("created index fail");
e.printStackTrace();
}
}
/**
* update Index
* */
public static void updateIndex() throws Exception{
Document document = new Document();
iW_config=new IndexWriterConfig(Version.LUCENE_44,analyzer);
iW_config.setOpenMode(OpenMode.CREATE_OR_APPEND);
directory=FSDirectory.open(new File(indexPath));
writer=new IndexWriter(directory,iW_config);
document=searchDocument("name","lucene");
document.removeField("name"); //更新所以必须在Document中删除了才能奇效
document.add(new StringField("name", "anewfile", Store.YES));
writer.updateDocument(new Term("name","lucene"),document);//此处要指定他的值和类型
writer.commit();
writer.close();
}
Lucene 4.0的更多相关文章
- 关于Lucene 3.0升级到Lucene 4.x 备忘
最近,需要对项目进行lucene版本升级.而原来项目时基于lucene 3.0的,很古老的一个版本的了.在老版本中中,我们主要用了几个lucene的东西: 1.查询lucene多目录索引. 2.构建R ...
- Lucene 6.0下使用IK分词器
Lucene 6.0使用IK分词器需要修改修改IKAnalyzer和IKTokenizer. 使用时先新建一个MyIKTokenizer类,一个MyIkAnalyzer类: MyIKTokenizer ...
- Lucene 4.0 正式版发布,亮点特性中文解读[转]
http://blog.csdn.net/accesine960/article/details/8066877 2012年10月12日,Lucene 4.0正式发布了(点击这里下载最新版),这个版本 ...
- lucene 3.0.2 + 多文件夹微博数据(时间,微博)构建索引
package lia.meetlucene; import java.io.File; import java.io.IOException; import java.util.LinkedList ...
- lucene 3.0.2 search 各种各样的Query类型
http://blog.sina.com.cn/s/blog_61d2047c010195mo.html lucene的这种各种各样的查询类型 1.TermQuery 最简单的Qu ...
- lucene 3.0.2 中文分词
package lia.meetlucene; import java.io.IOException; import java.io.Reader; import java.io.StringRead ...
- lucene 3.0.2 操作进阶
转自:Bannings http://blog.csdn.net/zhangao0086/article/details/ Analyzer(分词器) 分词器能以某种规则对关键字进行分词,将分好的词放 ...
- lucene 3.0.2 搜索
1.lucene 词频 转载:http://mxdxm.iteye.com/blog/989031 lucene in action作为action系列,确实坚持了其实用性的特色.全书花了很大的篇幅来 ...
- lucene 4.0学习
一:官方文件 http://lucene.apache.org/core/4_0_0/ ps:网上参考文章:http://www.cnblogs.com/xing901022/p/3933675.ht ...
随机推荐
- 代码片段--Makefile之大型工程项目子目录Makefile的一种通用写法
转载:http://blog.csdn.net/mo_hui123456/article/details/8929615 管理Linux环境下的C/C++大型项目,如果有一个智能的Build Syst ...
- 想了解JAVA的,看看(转载)
较新一篇 / 较旧一篇 编辑 |删除 | 复制链接 公开 想了解JAVA的,看看(转载)2009-03-01 15:41 (分类:默认分类) 先总结一下: J2SE (Core/Desktop) ...
- 关于Android中TextView显示多个空格
一.直接填写文字,输入多少,显示多少,如下: android:text="AAA AAA" ————————>显示:AAA AAA 二.通过设置str ...
- docker 容器数据管理
给容器添加一个数据卷 sudo docker run -d -P --name web -v /webapp training/webapp python app.py 可以在Dockerfile中使 ...
- ScriptTransformer
ScriptTransformer可能由java支持的JavaScript语言或者其他脚本语言写成的转换器.只支持Java 6以上版本. 例1: <dataConfig> <scri ...
- Flex学习总结
Flex SDK Flex框架类库.Flex编译环境.调式器.MXML.ActionScript编程语言以及其它工具组成,Flash Builder是其开发环境, Flash Player的工作模 ...
- NSOperation与GCD之间的关系
NSOperation与GCD的相同之处 1.NSOperation和NSOperationQueue实现多线程的步骤: 先将需要执行的操作封装到一个NSOperation对象中. 然后将NSOper ...
- Genymotion——PC上也能玩部落冲突 Clash of Clans
零.前言 部落冲突(Clash of Clans)是手机上一个很不错的联机对战游戏,安卓和iOS平台上都有. 最近玩这个略上瘾,前几天看到部落里有人说用模拟器可以在电脑上玩,就想自己试试. 不想看我啰 ...
- CMP指令(转)
刚刚看到了cmp指令,一开始有点晕.后来上网找了些资料,终于看明白了,为了方便初学者,我就简单写下我的思路吧.高手绕过,谢谢! cmp(compare)指令进行比较两个操作数的大小 例:cmp opr ...
- a different object with the same identifier value was already associated withthe session异常解决方案
异常信息: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was ...