Services中调用接口方法:
1.重新生成索引
/**
* 重新生成索引
*
* @return
*/
public String newIndex(String page) {
HelpSearchDomain helpSearchDomain = (HelpSearchDomain) getContextBean("helpSearchDomain");
BaseInfoAttributeDomain baseInfoAttributeDomain = (BaseInfoAttributeDomain) getContextBean("baseInfoAttributeDomain");
//设置分页对象信息
SplitPage sp = new SplitPage();
sp.setCurrentPage(Integer.parseInt(page));
sp.setPageSize(20);
List knowledgeList = baseInfoAttributeDomain.getAllBaseInfoAttribute("1", sp);
String path = "D:\\upload";
path = PropertiesUtil.get("PATH", path);
if (knowledgeList != null && knowledgeList.size() > 0) {
for (Iterator iterator = knowledgeList.iterator(); iterator.hasNext();) {
BaseInfoAttribute bi = (BaseInfoAttribute) iterator.next();
BaseInfoAttribute bia = null;
System.out.println(bi.getInfoType().getType());
if (bi.getInfoType().getType().equals(InfoType.ZSK)) {
bia = baseInfoAttributeDomain.findBaseInfoAttribute(bi.getId());
}
try {
helpSearchDomain.delKnowledgeIndex(path + "\\" + bia.getContent(), bia.getInfoType().getName(), path);//删除索引
} catch (Exception e) {
e.getMessage();
}
}
for (Iterator iterator = knowledgeList.iterator(); iterator.hasNext();) {
BaseInfoAttribute bi = (BaseInfoAttribute) iterator.next();
if (bi.getInfoType().getType().equals(InfoType.ZSK)) {
BaseInfoAttribute bia = baseInfoAttributeDomain.findBaseInfoAttribute(bi.getId());
helpSearchDomain.createKnowledgeIndex(false, path + "\\" + bia.getContent(), path, bia.getTitle(), bia.getCreatetime(), bia.getInfoType().getName(), String.valueOf(bi.getId()));
}
}
}
return "索引生成成功";
}
2.根据条件检索内容
/**
* 根据条件检索内容
*
* @param keyword
* @param type
* @param page
* @return
*/
public Object searchKnowledgeQuery(String keyword, String type, String page) {
HelpSearchDomain helpSearchDomain = (HelpSearchDomain) getContextBean("helpSearchDomain");
String path = "D:\\upload";
SplitPage sp = new SplitPage();
sp.setPageSize(18);
sp.setCurrentPage(page == null ? 1 : Integer.parseInt(page));
String isExist = helpSearchDomain.isExistsKnowlegeIndex(path);
List returnlist = new ArrayList();
List _list = new ArrayList();
List list = new ArrayList();
if (!isExist.equals("")) {
if (type.equals("3")) {//标题
list = helpSearchDomain.searchKnowlegeByKey("title", keyword, path, sp);
if (list != null && list.size() > 0) {
int len = list.size();
for (int i = 0; i < len; i++) {
Map m = (Map) list.get(i);
Map map = new HashMap();
map.put("id", m.get("knowlegeid"));
map.put("title", "<a href=\"javascript:void(0)\" onclick=\'getKnowledgeInfo(" + m.get("knowlegeid") + ")\'>" + m.get("title") + "</a>");
map.put("infoType", m.get("infoType"));
map.put("createtime", m.get("createtime"));
_list.add(map);
}
}
} else if (type.equals("2")) {// 内容
list = helpSearchDomain.searchKnowlegeByKey("contents", keyword, path, sp);
if (list != null && list.size() > 0) {
int len = list.size();
for (int i = 0; i < len; i++) {
Map m = (Map) list.get(i);
Map map = new HashMap();
map.put("id", m.get("knowlegeid"));
map.put("title", "<a href=\"javascript:void(0)\" onclick=\'getKnowledgeInfo(" + m.get("knowlegeid") + ")\'>" + m.get("title") + "</a>");
map.put("infoType", m.get("infoType"));
map.put("createtime", m.get("createtime"));
_list.add(map);
}
}
} else { //全文
list = helpSearchDomain.searchKnowlegeByKey("all", keyword, path, sp);
if (list != null && list.size() > 0) {
int len = list.size();
for (int i = 0; i < len; i++) {
Map m = (Map) list.get(i);
Map map = new HashMap();
map.put("id", m.get("knowlegeid"));
map.put("title", "<a href=\"javascript:void(0)\" onclick=\'getKnowledgeInfo(" + m.get("knowlegeid") + ")\'>" + m.get("title") + "</a>");
map.put("infoType", m.get("infoType"));
map.put("createtime", m.get("createtime"));
_list.add(map);
}
}
}
returnlist.add(_list);
returnlist.add(sp);
return returnlist;
} else {
return "";
}
}
有不懂得地方加:QQ413540158
分享到:
相关推荐
全文检索Lucene,书中详细介绍了Lucene的使用方法,和用lucene创建索引的demo,还介绍了检索框架Compass的使用,供大家学习参考!
基于lucene全文检索引擎实现的短文本匹配系统 ajax什么时候执行success,什么时候执行error 简单的说Ajax请求通过XMLHttpRequest对象发送请求,该对象有四个状态(readyState): 0-未初始化、1-正在初始化、2-发送...
* Apache Lucene全文检索和IKAnalyzer分词工具类 * <p>Company: 91注册码 * time:2014-04-22 * @author www.91zcm.com * @date * @version 1.1 */ public class LuceneUtil { /**索引创建的路径**/ ...
为了改善传统全文检索方法在检索效率上的不足,结合Lucene构建了一个全文检索系统模型。介绍了全文检索 的基本过程.该模型可用于中小型的全文检索系统的实现,同时可基于此模型开发定制个性化的搜索引擎。最后通过...
针对传统关系型数据库海量地名数据检索效率低下的问题,提出了一种盘古分词和Lucene全文检索相结合的地名数据库快速检索方法。首先,设计了一种地名数据表结构,比较了几种常用开源分词器的中文分词性能,并选用性能...
处理方法,提高全文检索系统的中文处理能力.整个模块基于当前最流行的搜索引擎架构 Lucene,实现了带有歧义消除功能的正向最大匹配算法.在系统评测方面,比较了该方法与现 有方法的区别,对于如何构建一个高效的...
public static String indexDirpath = "e:\\work\\zhzyk\\index";...第一次执行请把 indexWriter = new IndexWriter(indexDir, luceneAnalyzer, false);//true建立索引库,false追加索引库 false改为true
基本可以满足 检索电脑内文件的需求了 已经封装过了 直接指定检索目录和索引目录来创建索引.提供给学习者门参考... 直接通过调用静态方法来实现 深度分页检索.
针对中文检索的Lucene改进策略 为了提高基于Lucene中文检索系统的检索精度和效率,通过...理模块中采用提取特定数量的特征词来替代文档的方法能够有效提高Lucene检索系统的效率和精度,增强Lucene检索系统中文 的性能。
文档中包含Lucene4.0.0版本jar包,中文分词器jar包,Lucene实例代码 1:建立索引 2:各种搜索方式方法 3:删除索引 4:检查索引文件 5:恢复删除的索引 6:强制删除 7:更新索引 8:合并索引 9:高亮回显 供大家参考...
NULL 博文链接:https://baobeituping.iteye.com/blog/847085
该文档描述了Lunene的详细介绍,应用及实现的方法列子。
最简单的Lucene建立、搜索索引的方法,工程基于Myeclipse10
智周个人知识库--全文检索及标注系统 这是一个利用 lucene.net 技术开发的程序。用于查询个人计算机中的文件信息,包含了全文检索及标注系统。 随着计算机中文件的累积,常会有查找不易的问题。 解决方法1:”...
赠送jar包:lucene-core-6.6.0.jar; 赠送原API文档:lucene-core-6.6.0-javadoc.jar; 赠送源代码:lucene-core-6.6.0-sources.jar; 赠送Maven依赖信息文件:lucene-core-6.6.0.pom; 包含翻译后的API文档:lucene...
赠送jar包:lucene-grouping-6.6.0.jar; 赠送原API文档:lucene-grouping-6.6.0-javadoc.jar; 赠送源代码:lucene-grouping-6.6.0-sources.jar; 赠送Maven依赖信息文件:lucene-grouping-6.6.0.pom; 包含翻译后...
处理方法,提高全文检索系统的中文处理能力. 整个模块基于当前最流行的搜索引擎架构 Lucene ,实现了带有歧义消除功能的正向最大匹配算法. 在系统评测方面,比较了该方法与现 有方法的区别,对于如何构建一个高效的中文...
一、全文检索的简介 1、全文检索的介绍 1.1、数据分类 结构化数据:格式固定、长度固定、数据类型固定,如:数据库数据。 非结构化数据:格式不固定、长度不固定、数据类型不固定,如:word文档、pdf文档、邮件、...
1. lucence的出现的原因和目的 2 ...5. lucene可检索的内容 4 6. lucence与网络抓取的结合 4 6.1三种方案 4 6.2采用什么样的的文件存储格式 4 6.3如何使lucence增量更新索引 4 7. lucene索引权重 5
赠送jar包:lucene-highlighter-6.6.0.jar; 赠送原API文档:lucene-highlighter-6.6.0-javadoc.jar; 赠送源代码:lucene-highlighter-6.6.0-sources.jar; 赠送Maven依赖信息文件:lucene-highlighter-6.6.0.pom;...