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 ...
随机推荐
- SquashFs工具制作
下面是SquashFs.tar.gz的下载地址,解压后,直接执行其中的Makefile即可. SquashFs.tar.gz 说明: 制作squashfs格式的压缩镜像: ./mksquashfs . ...
- Jquery 扩展方法
$.fn是指jquery的命名空间,加上fn上的方法及属性,会对jquery实例每一个有效. 如扩展$.fn.abc() 那么你可以这样子:$("#div").abc(); 通常使 ...
- 从零开始学JAVA(04)-连接数据库MSSQL(JDBC准备篇)
在JAVA中可以使用JDBC连接数据库,不管是哪种数据库,首先必须下载驱动,包括Windows的MSSQL. 1.下载MSSQL的JDBC驱动,可以通过百度“Microsoft JDBC Driver ...
- iOS 修改网络图片的大小 宽和高
//image宽和高 好用 NSString *strTemplateHTML = [NSString stringWithFormat:@"<html><head> ...
- 重构13-Extract Method Object(提取方法对象)
重构来自于Martin Fowler的重构目录.你可以在这里找到包含简介的原始文章. 在我看来,这是一个比较罕见的重构,但有时却终能派上用场.当你尝试进行提取方法的重构时,需要引入大量的方法.在一个 ...
- 解决eclipse配置Tomcat时找不到server选项
集成Eclipse和Tomcat时找不到server选项: 按照网上的步骤如下: 在Eclipse中,窗口(window)——首选项(preferences)——服务器(Server)——运行时环境( ...
- 【java.math.BigInteger】常用函数
1. /* 返回此BigInteger的函数正负号. 此方法返回-1,0或1作为此BigInteger的值对应是负,零或正数. */ java.math.BigInteger.signum(BigIn ...
- noip2015day1 T1 4510 神奇的幻方
4510 神奇的幻方 noip2015day1 T1 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题解 查看运行结果 题目描述 Descripti ...
- CSS选择器笔记
一.元素选择符 序号 选择器 含义 1. * 通用元素选择器,匹配任何元素 2. E 标签选择器,匹配所有使用E标签的元素 3. .info class选择器,匹配所有class属性中包含info的元 ...
- Table of Contents - Redis
Getting Started 安装配置环境 Redis 命令 Keys Strings Lists Hashs Sets Sorted Sets Transactions Connection Se ...