Lucene写入和更新操作:            
if (id.equals("")) {
this.goodsService.save(goods); String goods_lucene_path = System.getProperty("user.dir")
+ File.separator + "luence" + File.separator + "goods";
File file = new File(goods_lucene_path);
if (!file.exists()) {
CommUtil.createFolder(goods_lucene_path);
}
LuceneVo vo = new LuceneVo();
vo.setVo_id(goods.getId());
vo.setVo_title(goods.getGoods_name());
vo.setVo_content(goods.getGoods_details());
vo.setVo_type("goods");
vo.setVo_store_price(CommUtil.null2Double(goods
.getStore_price()));
vo.setVo_add_time(goods.getAddTime().getTime());
vo.setVo_goods_salenum(goods.getGoods_salenum());
LuceneUtil lucene = LuceneUtil.instance();
LuceneUtil.setIndex_path(goods_lucene_path);
lucene.writeIndex(vo);
} else {
this.goodsService.update(goods); String goods_lucene_path = System.getProperty("user.dir")
+ File.separator + "luence" + File.separator + "goods";
File file = new File(goods_lucene_path);
if (!file.exists()) {
CommUtil.createFolder(goods_lucene_path);
}
LuceneVo vo = new LuceneVo();
vo.setVo_id(goods.getId());
vo.setVo_title(goods.getGoods_name());
vo.setVo_content(goods.getGoods_details());
vo.setVo_type("goods");
vo.setVo_store_price(CommUtil.null2Double(goods
.getStore_price()));
vo.setVo_add_time(goods.getAddTime().getTime());
vo.setVo_goods_salenum(goods.getGoods_salenum());
LuceneUtil lucene = LuceneUtil.instance();
LuceneUtil.setIndex_path(goods_lucene_path);
lucene.update(CommUtil.null2String(goods.getId()), vo);
}
     Lucene查询:

   LuceneResult pList = lucene.search(keyword,
CommUtil.null2Int(currentPage),
CommUtil.null2Int(store_price_begin),
CommUtil.null2Int(store_price_end), null, sort);
for (LuceneVo vo : pList.getVo_list()) {
Goods goods = this.goodsService.getObjById(vo.getVo_id());
pList.getGoods_list().add(goods);
}
CommUtil.saveLucene2ModelAndView("goods", pList, mv);
    
public static void saveLucene2ModelAndView(String type, LuceneResult pList, ModelAndView mv)
{
if (pList != null) {
if (type.equals("goods")) {
mv.addObject("objs", pList.getGoods_list());
}
if (type.equals("store")) {
mv.addObject("objs", pList.getStore_list());
}
mv.addObject("totalPage", Integer.valueOf(pList.getPages()));
mv.addObject("pageSize", Integer.valueOf(pList.getPageSize()));
mv.addObject("rows", Integer.valueOf(pList.getRows()));
mv.addObject("currentPage", new Integer(pList.getCurrentPage()));
mv.addObject(
"gotoPageFormHTML",
showPageFormHtml(pList.getCurrentPage(),
pList.getPages()));
}
}

Lucene全文检索的更多相关文章

  1. Apache Lucene(全文检索引擎)—创建索引

    目录 返回目录:http://www.cnblogs.com/hanyinglong/p/5464604.html 本项目Demo已上传GitHub,欢迎大家fork下载学习:https://gith ...

  2. Lucene全文检索技术

    Lucene全文检索技术 今日大纲 ●    搜索的概念.搜索引擎原理.倒排索引 ●    全文索引的概念 ●    使用Lucene对索引进行CRUD操作 ●    Lucene常用API详解 ●  ...

  3. 使用Lucene全文检索并使用中文版和高亮显示

    使用Lucene全文检索并使用中文版和高亮显示 中文分词需要引入 中文分词发的jar 包,咱们从maven中获取 <!-- lucene中文分词器 --> <dependency&g ...

  4. lucene全文检索基础

    全文检索是一种将文件中所有文本与检索项匹配的文字资料检索方法.比如用户在n个小说文档中检索某个关键词,那么所有包含该关键词的文档都返回给用户.那么应该从哪里入手去实现一个全文检索系统?相信大家都听说过 ...

  5. lucene 全文检索工具的介绍

    Lucene:全文检索工具:这是一种思想,使用的是C语言写出来的 1.Lucene就是apache下的一个全文检索工具,一堆的jar包,我们可以使用lucene做一个谷歌和百度一样的搜索引擎系统 2. ...

  6. Lucene 全文检索 Lucene的使用

    Lucene  全文检索  Lucene的使用 一.简介: 参考百度百科: http://baike.baidu.com/link?url=eBcEVuUL3TbUivRvtgRnMr1s44nTE7 ...

  7. Lucene全文检索_分词_复杂搜索_中文分词器

    1 Lucene简介 Lucene是apache下的一个开源的全文检索引擎工具包. 1.1 全文检索(Full-text Search)  1.1.1 定义 全文检索就是先分词创建索引,再执行搜索的过 ...

  8. Lucene 全文检索

    基于 lucene 8 1 Lucene简介 Lucene是apache下的一个开源的全文检索引擎工具包. 1.1 全文检索(Full-text Search) 全文检索就是先分词创建索引,再执行搜索 ...

  9. Apache Lucene(全文检索引擎)—分词器

    目录 返回目录:http://www.cnblogs.com/hanyinglong/p/5464604.html 本项目Demo已上传GitHub,欢迎大家fork下载学习:https://gith ...

  10. lucene全文检索---打酱油的日子

    检索内容,一般的程序员第一时间想到的是sql的like来做模糊查询,其实这样的搜索是比较耗时的.已经有lucene帮我们 封装好了,lucene采用的是分词检索等策略. 1.lucene中的类描述 I ...

随机推荐

  1. 使用OpenSSL API进行安全编程

    http://www.ibm.com/developerworks/cn/linux/l-openssl.html OpenSSL API 的文档有些含糊不清.因为还没有多少关于 OpenSSL 使用 ...

  2. BZOJ 1143 祭祀

    Description 在遥远的东方,有一个神秘的民族,自称Y族.他们世代居住在水面上,奉龙王为神.每逢重大庆典, Y族都会在水面上举办盛大的祭祀活动.我们可以把Y族居住地水系看成一个由岔口和河道组成 ...

  3. Mysql中类似于nvl()函数的ifnull()函数

    IFNULL(expr1,expr2) 如果expr1不是NULL,IFNULL()返回expr1,否则它返回expr2.IFNULL()返回一个数字或字符串值,取决于它被使用的上下文环境. mysq ...

  4. IOS中用模型取代字典的好处

    使用字典的坏处 一般情况下,设置数据和取出数据都是用“字符串类型的key”,编写这些key时,编译器不会有任何友情提示,需要手敲 dict[@“name”]=@“Kevin”; NSString *n ...

  5. PPI是什么?如何计算?

    PPI,英文全称:pixels per inch,即像素每英寸,也叫像素密度,它是描述在水平的和垂直的方向上,每英寸距离的图像包含的像素(pixel)数目.因此PPI数值越高,即代表显示屏能够以越高的 ...

  6. xp下删除windows7,无法删除windows7文件夹,无法删除windows7文件,双系统卸载,取得文件权限

    http://blog.csdn.net/lanmanck/article/details/5722050 ---------------------------------------------- ...

  7. mangos搭建

    github地址:https://github.com/mangos/MaNGOS MaNGOS 是( Massive Network Game Object Server) 的缩写.由于暴雪公司对类 ...

  8. VS2010安装Visual Assist

    Visual Assist X是一款非常好的Microsoft Visual Studio 2005和Visual Studio .NET插件,支持C/C++,C#,ASP,Visual Basic, ...

  9. windows下sqlite3静态库和动态库的编译

    1.下载sqlite3源码:http://www.sqlite.org/download.html 主要是sqlite-amalgamation-XXXXXXX.zip.sqlite-dll-win3 ...

  10. Ubuntu 14.04 dnw配置

    之前写的Ubuntu嵌入式环境搭建没有讲怎么配置dnw下载工具,使用dnw还得用红帽,今天配置好了ubuntu下的dnw,记录一下 首先先下载dnw的源码,这是我上传的提供给大家下载:http://p ...