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 ...
随机推荐
- Laravel 5.0 之命令及处理程序
本文译自 Matt Stauffer 的 系列文章 . 本文中涉及的新功能都是关于 Commands 的,这些特性在 Laravel 旧版本中已经有了,但是在 Laravel 5.0 中变得更加好用了 ...
- c#winform将全局异常抛出,不用大量写try()catch()
一.在program.cs处完善成如下,但是这样后只能抛出主线程(UI)的错误,所以请看第二步 /// 应用程序的主入口点. /// </summary> [STAThread] stat ...
- CSU OJ PID=1514: Packs 超大背包问题,折半枚举+二分查找。
1514: Packs Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 61 Solved: 4[Submit][Status][Web Board] ...
- nodejs 实现 http proxy 透明转发
这两天需要安装一个Linux虚拟机,接下来要通过 yum 来安装需要的软件. 因单位的网络需要通过代理才能访问外网,公司代理服务器:proxy.xxxx.com,给yum增加了proxy设置: # v ...
- Android开发——实现固定在ScrollView顶部的View,类似于新浪微博的评论列表的顶部
现在很多App都实现了这个功能,例如新浪微博评论页面的评论.转发.赞的数字可以固定在屏幕上方.我个人很喜欢这种设计,所以利用一点空余时间简单实现了一个类似的功能. 先来看一下上面这张图的效果 这个是新 ...
- 1. SQL Server服务器监控实现方法
对于服务器的监控,和对数据库的监控,很少有合二为一的工具,如果有的话,一般是付费软件,或者自行开发的工具.所以如果不想购买软件,也不想花精力去开发的话,可以结合一些免费/开源的工具.自定义脚本,来完成 ...
- HDU 4424 Conquer a New Region
http://acm.hdu.edu.cn/showproblem.php?pid=4424 [题目大意] 给你N个点和N-1条边的连通图,也就是说任意两点间的路径是唯一的.每条边有个权值,从一点到另 ...
- Unity之屏幕画线
using UnityEngine;using System.Collections; public class DrawRectangle : MonoBehaviour { public Colo ...
- WinFrom“动态”WebService
1.首先添加一个WebService: 2.输入地址....Ok: 3.在WebService用到的类上按F12: 4.进入类中,找到其构造函数: 5.修改其构造函数为代参数,并且让this.Url= ...
- ASP.NET缓存全解析3:页面局部缓存 转自网络原文作者李天平
有时缓存整个页面是不现实的,因为页的某些部分可能在每次请求时都需要变化.在这些情况下,只能缓存页的一部分.顾名思义,页面部分缓存是将页面部分内容保存在内存中以便响应用户请求,而页面其他部分内容则为动态 ...