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. 去除VS2010中中文注释下的红色波浪线

    1,中文注释以分号结尾 2,Assist X 菜单栏->Assist X Option->Underline 选择“min”.

  2. 一个获取Android手机root权限的程序

    PermRoot.bat可以获取root权限. IsRoot.bat可以测试是否拥有root权限. UnRoot.bat可以清除root权限. 下载地址: http://pan.baidu.com/s ...

  3. ubuntu wubi安装注意事项

    从这个镜像下载 http://mirrors.163.com/ubuntu-releases/12.10/ ubuntu-12.10-desktop-amd64.iso 和 wubi.exe然后放到同 ...

  4. c# appdomain

    http://www.cnblogs.com/Terrylee/archive/2005/11/28/285809.html

  5. 对话Facebook人工智能实验室主任、深度学习专家Yann LeCun

    对话Facebook人工智能实验室主任.深度学习专家Yann LeCun Yann LeCun(燕乐存),Facebook人工智能实验室主任,NYU数据科学中心创始人,计算机科学.神经科学.电子电气科 ...

  6. JavaScript框架设计 第14章 动画引擎

    easing-js <!DOCTYPE html> <html> <head> <meta charset="utf-8"> < ...

  7. 【模拟】Codeforces 691B s-palindrome

    题目链接: http://codeforces.com/problemset/problem/691/B 题目大意: 求一个字符串是不是镜像的(不是回文).是输出TAK否则RE. 题目思路: [模拟] ...

  8. supesite 标签语法

    http://blog.sina.com.cn/s/blog_a3c7706701018c8o.html

  9. sublime text3安装SublimeREPL--解决不能运行input()的问题

    原文地址:http://blog.chinaunix.net/uid-12014716-id-4269991.html 一.安装包管理器(如果已经安装可以忽略) 1.简单的安装方法:使用Ctrl+`快 ...

  10. HDU 畅通工程系列

    畅通工程系列都是比较裸的最小生成树问题,且是中文题目,不赘述了. 1.HDU 1863 畅通工程 题意:一个省有很多村庄,其中一些之间是可以建公路的,每条公路都需要不同的代价,问代价最小的情况下将所有 ...