关于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的更多相关文章

  1. 关于Lucene 3.0升级到Lucene 4.x 备忘

    最近,需要对项目进行lucene版本升级.而原来项目时基于lucene 3.0的,很古老的一个版本的了.在老版本中中,我们主要用了几个lucene的东西: 1.查询lucene多目录索引. 2.构建R ...

  2. Lucene 6.0下使用IK分词器

    Lucene 6.0使用IK分词器需要修改修改IKAnalyzer和IKTokenizer. 使用时先新建一个MyIKTokenizer类,一个MyIkAnalyzer类: MyIKTokenizer ...

  3. Lucene 4.0 正式版发布,亮点特性中文解读[转]

    http://blog.csdn.net/accesine960/article/details/8066877 2012年10月12日,Lucene 4.0正式发布了(点击这里下载最新版),这个版本 ...

  4. lucene 3.0.2 + 多文件夹微博数据(时间,微博)构建索引

    package lia.meetlucene; import java.io.File; import java.io.IOException; import java.util.LinkedList ...

  5. lucene 3.0.2 search 各种各样的Query类型

    http://blog.sina.com.cn/s/blog_61d2047c010195mo.html     lucene的这种各种各样的查询类型 1.TermQuery       最简单的Qu ...

  6. lucene 3.0.2 中文分词

    package lia.meetlucene; import java.io.IOException; import java.io.Reader; import java.io.StringRead ...

  7. lucene 3.0.2 操作进阶

    转自:Bannings http://blog.csdn.net/zhangao0086/article/details/ Analyzer(分词器) 分词器能以某种规则对关键字进行分词,将分好的词放 ...

  8. lucene 3.0.2 搜索

    1.lucene 词频 转载:http://mxdxm.iteye.com/blog/989031 lucene in action作为action系列,确实坚持了其实用性的特色.全书花了很大的篇幅来 ...

  9. lucene 4.0学习

    一:官方文件 http://lucene.apache.org/core/4_0_0/ ps:网上参考文章:http://www.cnblogs.com/xing901022/p/3933675.ht ...

随机推荐

  1. yii2-admin 插件使用简要教程

    yii2的访问权限默认是由自带的rbac组件在管理,需要自己编写相应的规则去实现权限管理,无图形界面.yii2-admin是将rbac的管理可视化,只需要点几下鼠标就能设置好简单的规则. 本教程中软件 ...

  2. 关于测试Windows电脑端口的命令 —— telnet用法

    telnet服务在win7默认是打开的,如果没有打开要在电脑中打开. 命令格式:telnet ip port 例如:telnet 127.0.0.1 80 或者 telnet www.XXX.com ...

  3. NLP自然语言处理学习笔记二(初试)

    前言: 用Python对自然语言处理有很好的库.它叫NLTK.下面就是对NLTK的第一尝试. 安装: 1.安装Pip 比较简单,得益于CentOS7自带的easy_install.执行一行命令就可以搞 ...

  4. [Arduino] Arduino Uno R3 中文介绍

    Arduino UNO是Arduino USB接口系列的最新版本,作为Arduino平台的参考标准模板.UNO的处理器核心是ATmega328,同时具有14路数字输入/输出口(其中6路可作为PWM输出 ...

  5. Java基础知识强化之IO流笔记78:NIO之 FileChannel

    Java NIO中的FileChannel是一个连接到文件的通道.可以通过文件通道读写文件. FileChannel无法设置为非阻塞模式,它总是运行在阻塞模式下. 1. 打开FileChannel 在 ...

  6. web开发人员须知的web缓存知识–将数据缓存到浏览器端Net实现

    现实中,服务器在向浏览器发送的数据中,一部分数据是不经常更新的,如果能将这部分数据缓存到浏览器端,将会大大降低传输的数据,提高应用的性能.通过Expires策略,可以使用HTTP 协议定义的缓存机制将 ...

  7. 【Android 界面效果16】关于android四大组件的总结

    Android四大组件:Activity.Service.Broadcast receiver.Content provider 在Android中,一个应用程序可以使用其它应用程序的组件,这是And ...

  8. linux之磁盘配额(quota)

    1.什么是quota 简单的说就是限制用户对磁盘空间的使用量. 因为Linux是多用户多任务的操作系统,许多人共用磁盘空间,为了合理的分配磁盘空间,于是就有了quota的出现. 2.quota的用途  ...

  9. mysql优化方法

    1.选取最适用的字段属性 MySQL可以很好的支持大数据量的存取,但是一般说来,数据库中的表越小,在它上面执行的查询也就会越快.因此,在创建表的时候,为了获得更好的性能,我们可以将表中字段的宽度设得尽 ...

  10. 怒刷DP之 HDU 1069

    Monkey and Banana Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...