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 ...
随机推荐
- 记录一次linux线上服务器被黑事件
1.原因:本来在家正常休息了,我们放在上海托管机房的线上服务器突然蹦了远程不了,服务启动不了,然后让上海机房重启了一次,还是直接挂了,一直到我远程上才行. 2.现象:远程服务器发现出现这类信息 Hi, ...
- arcgis gdb含下划线_和%的查询 by gisoracle
XMMC LIKE '%\_%' ESCAPE '\' by gisoracle 2015.1.25 XMMC LIKE '%\%%' escape '\' ...
- 【MYSQL】常用命令备忘录
source 不接路径时,查找文件的路径是执行mysql命令时的路径 接路径时,使用路径+filename [root@wordpressserver mysql]# vi demo.mysql [r ...
- epoll实现linux进程通信
server.c #include <stdio.h> #include <stdlib.h> #include <string.h> #include <s ...
- iOS 下拉刷新 上拉加载实现原理
1.下拉刷新 实现原理 if (scrollView.contentOffset.y < -100) { [UIView animateWithDuration:1.0 animations:^ ...
- [原创] Web UI 自动化日期控件的处理
序 在构建自动化套件的过程中,日期操作是一件很重要也很频繁的事情.有的日期控件的div层级结构复杂,同一个类型的日期控件在多个子系统中的表现形式也大相径庭.多数工程师为了避免重复的工作,会封装抽象一个 ...
- C++中模板函数或模板类中关键词class和typename
##区别 基本上来说,class和typename几乎没有区别.在可以使用class的地方都可以使用typename,在使用typename的地方也几乎可以使用class. 可以看出我加黑了两个子:几 ...
- 强大的矢量图形库:Raphael JS 中文帮助文档及教程
Raphael 是一个用于在网页中绘制矢量图形的 Javascript 库.它使用 SVG W3C 推荐标准和 VML 作为创建图形的基础,你可以通过 JavaScript 操作 DOM 来轻松创建出 ...
- MySQL中/*!40100注释
MySQL中的注释 MySQL中的注释有三种: # 注释内容 -- 注释内容 /* 注释内容*/ 但是,在导出的SQL文件中,也会看到类似如下内容的注释: CREATE DATABASE `blog` ...
- Umbraco(4)-Outputting the Document Type Properties(翻译文档)
翻译原文地址:http://www.ncloud.hk/%E6%8A%80%E6%9C%AF%E5%88%86%E4%BA%AB/umbraco4outputting-the-document-typ ...