Re: [J2EE] Spring MVC 实现搜寻文章功能 (Lucene..)

楼主: phstudy (study)   2014-08-06 01:42:36
今天玩Spring Data Elasticsearch,有顺便写了一个小范例,给你参考一下 :D
专案位置: https://github.com/phstudy/SpringMVC-SpringDataElasticsearch
1. 设定elasticsearch ip
/src/main/webapp/WEB-INF/spring/elasticsearch-context.xml
2. Spring MVC的分页参数接收方法
/src/main/java/org/phstudy/sample/controller/rest/BookRestController.java
里面有Pageable, HttpServletRequest与@RequestParam的使用范例
3. 前端页面
/src/main/webapp/WEB-INF/views/book.jsp
ps.前端的js写的有点差,不过基本原理不变
※ 引述《ek0424 ()》之铭言:
: 最近小弟接触了Lucene相关的开源搜寻引擎,有接触到Elastisearch,Solr等
: 想写一个简单的搜寻的网页接口,大概就像是google或是yahoo,github那样
: 可以下几个关键字后做搜寻。
: 目前我只会用Elasticsearch API下关键字把全部相关资料捞出来,但我不知道怎么
: 做搜寻的分页机制,像是如果关键字是"Java",可以找到20000万笔跟Java有关的资料
: 如果我想分页显示在前端,每页有20比资料,总共分1000页,要怎么实做呢?
: 我目前都是用Spring MVC的框架在写,不知道有没有大大能够给个范例或教学教教我?
: 谢谢各位~
作者: ek0424   2014-08-06 12:34:00
非常感谢!!
楼主: phstudy (study)   2014-08-07 00:07:00
范例加了你先前提到的整页重整的做法

Links booklink

Contact Us: admin [ a t ] ucptt.com