大漠駝鈴

          置身浩瀚的沙漠,方向最為重要,希望此blog能向大漠駝鈴一樣,給我方向和指引。
          Java,Php,Shell,Python,服務器運維,大數據,SEO, 網站開發、運維,云服務技術支持,IM服務供應商, FreeSwitch搭建,技術支持等. 技術討論QQ群:428622099
          隨筆 - 238, 文章 - 3, 評論 - 117, 引用 - 0

          導航

          <2009年3月>
          22232425262728
          1234567
          891011121314
          15161718192021
          22232425262728
          2930311234

          公告

          本博客提供技術討論QQ群:428622099,希望志同道合的朋友加入群,共同進步和學習。
          如果您覺得本博客還可以,請支持網頁頂部的廣告,謝謝。

          常用鏈接

          留言簿(11)

          隨筆分類(214)

          隨筆檔案(239)

          文章分類(1)

          文章檔案(1)

          相冊

          作品

          • 北京韋爾科技有限公司
          • 北京韋爾科技有限公司是一家從事互聯網相關技術研發型的公司,對外提供互聯網相關技術培訓,產品研發等。
          • 映目圖文直播官網
          • 圖文直播-讓直播更簡單更有效。圖文直播基于文字、圖片、視頻的直播方式,直播可嵌入APP、網站和微信公眾平臺,提供多種方式面向企業個人支持在線直播云服務、遠程部署服務、技術支持服務!
          • 映目官網
          • 映目是一體化自助式全流程的數字會議云平臺,擁有直播、活動、簽到、互動、會務、云攝影子產品,提供線上線下一體化服務,包含會議網站、簽到、互動、直播、數據統計、攝影、攝像、速記、翻譯等全流程的線上線下解決方案,辦活動找映目,高效率、高質量、低成本,映目讓會議活動舉辦更簡單。
          • 映目照片直播官網
          • 映目照片直播,專業的照片直播、圖片直播、云攝影商業紀實攝影服務供應商,5秒數快傳、3分鐘快修即刻呈現,全國拍攝發布會、慶典、年會、展覽、活動、沙龍、派對、講座、課程、會議、文化演出、體育賽事等活動

          搜索

          •  

          積分與排名

          • 積分 - 671215
          • 排名 - 69

          最新評論

          閱讀排行榜

          評論排行榜

          Lucene索引查詢分頁實例

          一、輸入關鍵字的lucene.html
          <html>
          <body>
          <form name="form1" method="post" action="search.jsp">
             請輸入關鍵字:<input type="text" name="keyword">
            <input type="submit" name="Submit" value="提交">
          </form>
          </body>
          </html>

           二、進行搜索和顯示結果的search.jsp <%@ page contentType="text/html; charset=gb2312" %>
          <%@ page import="java.util.*" %>
          <%@ page import="java.text.SimpleDateFormat" %>
          <%@ page import = "org.apache.lucene.analysis.standard.StandardAnalyzer" %>
          <%@ page import="org.apache.lucene.index.IndexReader" %>
          <%@ page import="org.apache.lucene.document.Document" %>
          <%@ page import="org.apache.lucene.search.IndexSearcher" %>
          <%@ page import="org.apache.lucene.search.Hits" %>
          <%@ page import="org.apache.lucene.search.Query" %>
          <%@ page import="page.Pagination" %> <%@ page import="org.apache.lucene.queryParser.QueryParser" %>
          <%@ page import ="org.apache.lucene.analysis.Analyzer" %>
          <%

            String queryString = request.getParameter("keyword");  

          if (queryString == null||queryString.length()==0){
          out.println("搜索關鍵字不能為空");

          }else{
          queryString=new String(queryString.getBytes("ISO8859_1"));
          String indexPath=getServletContext().getRealPath("/")+"index";
          boolean error = false;
          Document doc;

          IndexSearcher searcher = null;
          Query query = null;
          Hits hits = null;

          try {
          searcher = new IndexSearcher(IndexReader.open(indexPath));
          } catch (Exception e) {
          out.print("沒有找到索引文件!");
          out.print(e.getMessage());
          error = true;
          }
          if (error == false) {
          Analyzer analyzer = new StandardAnalyzer();
          try {
          query = QueryParser.parse(queryString, "Article_name", analyzer);
          } catch (Exception e) {
          out.print(e.getMessage());
          error = true;

          }
          }
          if (error == false && searcher != null) {

          hits = searcher.search(query);
          if (hits.length() == 0) {
          out.print("對不起!沒有找到你所需要的資源. ");
          error = true;
          }
          }
          if (error == false && searcher != null) {
          out.print("搜索關鍵字:"+ queryString+ "");
          //Pagination類是網上下載的,需要傳遞一個向量,你可以改,這樣就不用做二遍事
          Vector list=new Vector();
          for(int i=0;i< hits.length();i++){
          doc = hits.doc(i);
          list.add(doc);
          }

          out.print("找到的資源");
          Pagination pagination = null;
          String pageNumber = request.getParameter("pageNumber");

          int showItemNumber = 10;
          if (pageNumber == null) {
          pageNumber = "1";
          }
          String HTML = "";
          if (list != null && list.size() > 0) {
          pagination = new Pagination();
          pagination.setPageNumber(Integer.parseInt(pageNumber));
          pagination.setShowItemNumber(showItemNumber);
          pagination.setVisitPageURL("search.jsp?keyword="+queryString);
          list =(Vector) pagination.interceptListByStarItemNumber(list);
          for(int i=0;i< list.size();i++)
          {
          doc =(Document) list.get(i);
          String A_id=doc.get("Article_id");
          String doctitle = doc.get("Article_name");
          String url = doc.get("File_name")+"?id="+A_id;

          out.print("< a +doctitle+"");
          }
          HTML = pagination.buildHTML("600");
          out.print(HTML);
          }
          }

          }

          posted on 2009-03-03 15:56 草原上的駱駝 閱讀(1375) 評論(0)  編輯  收藏 所屬分類: 搜索服務

          主站蜘蛛池模板: 清涧县| 乌兰察布市| 乌拉特前旗| 长汀县| 耿马| 泰来县| 古交市| 衢州市| 武汉市| 邻水| 钟祥市| 广宁县| 松溪县| 温泉县| 营山县| 宁武县| 吉木乃县| 嘉禾县| 岳西县| 裕民县| 建宁县| 安庆市| 宜黄县| 富民县| 文山县| 通辽市| 霍林郭勒市| 江门市| 凤山县| 正安县| 喀什市| 灵武市| 平顺县| 平山县| 万全县| 建水县| 高要市| 长宁区| 河西区| 景泰县| 山阳县|