lucene关于IndexReader总结
IndexReader。使用过程中有时会出现document被删除,reader还是原来的reader没有改变,所以使用openifchanged保证,
又因为IndexReader 初始化很耗费资源所以放在静态代码块里
private static Directory directory = null;
private static IndexReader reader = null;
static {
try {
directory = FSDirectory.open(new File("E:/lucene/index02"));
reader = IndexReader.open(directory);
} catch (Exception e) {
e.printStackTrace();
}
}
public IndexSearcher getIndexSearcher() {
try {
IndexReader tr = IndexReader.openIfChanged(reader);
if (tr != null) {
reader.close();
reader = tr;
}
return new IndexSearcher(reader);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
lucene关于IndexReader总结的更多相关文章
- Lucene IndexReader,IndexWriter,IndexSearcher 缓存应用
1.IndexManager类,用于提供IndexReader,IndexWriter,IndexSearcher获取接口 import java.io.File; import java.io.IO ...
- Cache Lucene IndexReader with Apache Commons Pool
IndexReaderFactory.java 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 2 ...
- 用lucene替代mysql读库的尝试
采用lucene对mysql中的表建索引,并替代全文检索操作. 备注:代码临时梳理很粗糙,后续修改. import java.io.File; import java.io.IOException; ...
- Lucene搜索方式大合集
package junit; import java.io.File; import java.io.IOException; import java.text.ParseException; imp ...
- 【Lucene】三个高亮显示模块的简单示例-Highlighter
Lucene针对高亮显示功能提供了两种实现方式,分别是Highlighter和FastVectorHighlighter 这里的三个示例都是使用Highlighter: 示例代码: package c ...
- lucene 索引 demo
核心util /** * Alipay.com Inc. * Copyright (c) 2004-2015 All Rights Reserved/ */ package com.lucene.de ...
- lucene 搜索demo
package com.ljq.utils; import java.io.File; import java.util.ArrayList; import java.util.List; impor ...
- Lucene 简单API使用
本demo 简单模拟实现一个图书搜索功能. 模拟向数据库添加数据的时候,添加书籍索引. 提供搜索接口,支持按照书名,作者,内容进行搜索. 按默认规则排序返回搜索结果. Jar依赖: <prope ...
- Lucene学习之一:使用lucene为数据库表创建索引,并按关键字查询
最近项目中要用到模糊查询,开始研究lucene,期间走了好多弯路,总算实现了一个简单的demo. 使用的lucene jar包是3.6版本. 一:建立数据库表,并加上测试数据.数据库表:UserInf ...
随机推荐
- hive(在大数据集合上的类SQL查询和表)学习
1.jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true&characterEncoding=UTF-8&use ...
- python语言的jenkinapi
# coding:utf-8 from jenkinsapi.jenkins import Jenkins # 实例化Jenkins对象,传入地址+账号+密码 j = Jenkins("ht ...
- windows中卸载Jenkins
背景: 之前安装的Jenkins没有pipeline选项,可能是之前安装时没有选择建议插件.后面使用最新版本时还是没有插件 解决: 卸载Jenkins,删除掉C:\Users\用户名\.jenkins ...
- xshell无法连接Ubuntu的解决办法
使用workstations14安装完Ubunu后,网络连接方式为NAT模式(N):用于共享主机的IP地址 此时想用xshell连接此虚拟机但是提示连接失败,但是宿主机和虚拟机互相都能ping通,且虚 ...
- mvc4验证码&输出图像的处理方式
/// <summary> /// 绘制验证码 /// </summary> /// <returns></returns> public Action ...
- unable browse url when InfoPath Convert to Connection File
You must actived the windows feature "Desktop Experience" on the server : http://blogs.tec ...
- Data Base Oracle 常用命令
Data Base Oracle 常用命令 1.登录:(不需要密码,属于管理员权限) conn /as sysdba; 2.查看数据库存储位置: select name from v$datafil ...
- 「NOIP 2013」 货车运输
题目链接 戳我 \(Solution\) 这一道题直接用\(kruskal\)重构树就好了,这里就不详细解释\(kruskal\)重构树了,如果不会直接去网上搜就好了.接下来讲讲详细过程. 首先构建\ ...
- lua luna工具库
luna工具库 概述 luna库提供了几个lua开发的常见辅助功能: lua/c++绑定 lua序列化与反序列化 变长整数编码,用于lua序列化,当然也可以方便的用于其他场合 这里把代码编译成了动态库 ...
- 《锋利的jQuery 第二版》chapter 1~
chapter 1 认识 jQuery jquery.js(开发版),jquery.min.js(生产版) window.onload 与 $(document).ready() 的对比: jquer ...