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 ...
随机推荐
- Joy of Programming: Understanding Bit-fields in C
转:http://www.linuxforu.com/2012/01/joy-of-programming-understanding-bit-fields-c/ By S.G. Ganesh on ...
- http协议学习(一)http状态
整理了一个脑图,算作是<图解HTTP>的读书笔记,这本书有很多插图,适合初学者入门理解. 讲解网络协议的书不多 其中两本被人们奉为圣经 <TCP/IP详解 卷一> <H ...
- docker 连接容器
1.通过端口映射 sudo docker run -d -P training/webapp python app.py 容器有一个内部网络和IP地址(在使用Docker部分我们使用docker in ...
- Border绘制虚线框(转)
<Grid> <Border HorizontalAlignment="Center" VerticalAlignment="Center" ...
- iOS- SQLite3的基本使用
iOS- 简单说说iOS移动客户端SQLite3的基本使用 1.为什么要使用SQLite3? •大量数据需要存储 •管理数据,存储数据 SQLite是一种关系型数据库(也是目前移动客户端的主 ...
- Wamp,XAMPP 无法启动,端口未占用的故障处理
打开服务管理里:Service.msc 找到服务:WinHttpAutoProxySvc(WinHTTP 实现了客户端 HTTP 堆栈并向开发人员提供 Win32 API 和 COM 自动化组件以供发 ...
- C# 使用代码来操作 IIS
由于需要维护网站的时候,可以自动将所有的站点HTTP重定向到指定的静态页面上. 要操作 IIS 主要使用到的是“Microsoft.Web.Administration.dll”. 该类库不可以在引用 ...
- SQL查询中的in与join效率比较
大多数情况下,程序员比较喜欢使用in来查询符合某些条件的数据,最近在查询某个角色有哪些用户的方法中,使用了in语句: ) FROM baseuser AND BaseUser.Id IN (SELEC ...
- Android下拉刷新-SwipeRefreshLayout,RecyclerView完全解析之下拉刷新与上拉加载SwipeRefreshLayout)
SwipeRefrshLayout是Google官方更新的一个Widget,可以实现下拉刷新的效果.该控件集成自ViewGroup在support-v4兼容包下,不过我们需要升级supportlibr ...
- ubuntu 换源
经过自己一番折腾后,发现用这个方法换源最简单.直接. sudo vi /etc/apt/sources.list 把sources.list里面的内容全部替换为一下内容 deb http://mirr ...