Return-Path: Delivered-To: apmail-lucene-java-commits-archive@www.apache.org Received: (qmail 32658 invoked from network); 26 Aug 2009 21:47:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 26 Aug 2009 21:47:33 -0000 Received: (qmail 47643 invoked by uid 500); 26 Aug 2009 21:47:33 -0000 Delivered-To: apmail-lucene-java-commits-archive@lucene.apache.org Received: (qmail 47578 invoked by uid 500); 26 Aug 2009 21:47:33 -0000 Mailing-List: contact java-commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-dev@lucene.apache.org Delivered-To: mailing list java-commits@lucene.apache.org Received: (qmail 47569 invoked by uid 99); 26 Aug 2009 21:47:33 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Aug 2009 21:47:33 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Aug 2009 21:47:30 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4FB012388868; Wed, 26 Aug 2009 21:47:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r808196 - /lucene/java/trunk/src/jsp/results.jsp Date: Wed, 26 Aug 2009 21:47:09 -0000 To: java-commits@lucene.apache.org From: markrmiller@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090826214709.4FB012388868@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: markrmiller Date: Wed Aug 26 21:47:08 2009 New Revision: 808196 URL: http://svn.apache.org/viewvc?rev=808196&view=rev Log: update webapp demo to non deprecated usage Modified: lucene/java/trunk/src/jsp/results.jsp Modified: lucene/java/trunk/src/jsp/results.jsp URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/jsp/results.jsp?rev=808196&r1=808195&r2=808196&view=diff ============================================================================== --- lucene/java/trunk/src/jsp/results.jsp (original) +++ lucene/java/trunk/src/jsp/results.jsp Wed Aug 26 21:47:08 2009 @@ -1,4 +1,4 @@ -<%@ page import = " javax.servlet.*, javax.servlet.http.*, java.io.*, org.apache.lucene.analysis.*, org.apache.lucene.analysis.standard.StandardAnalyzer, org.apache.lucene.document.*, org.apache.lucene.index.*, org.apache.lucene.search.*, org.apache.lucene.queryParser.*, org.apache.lucene.demo.*, org.apache.lucene.demo.html.Entities, java.net.URLEncoder" %> +<%@ page import = " javax.servlet.*, javax.servlet.http.*, java.io.*, org.apache.lucene.analysis.*, org.apache.lucene.analysis.standard.StandardAnalyzer, org.apache.lucene.document.*, org.apache.lucene.index.*, org.apache.lucene.store.*, org.apache.lucene.search.*, org.apache.lucene.queryParser.*, org.apache.lucene.demo.*, org.apache.lucene.demo.html.Entities, java.net.URLEncoder, org.apache.lucene.util.Version" %> <% /* @@ -31,18 +31,19 @@ String indexName = indexLocation; //local copy of the configuration variable IndexSearcher searcher = null; //the searcher used to open/search the index Query query = null; //the Query created by the QueryParser - Hits hits = null; //the search results + TopDocs hits = null; //the search results int startindex = 0; //the first index displayed on this page int maxpage = 50; //the maximum items displayed on this page String queryString = null; //the query entered in the previous page String startVal = null; //string version of startindex String maxresults = null; //string version of maxpage int thispage = 0; //used for the for/next either maxpage or - //hits.length() - startindex - whichever is + //hits.totalHits - startindex - whichever is //less try { - searcher = new IndexSearcher(indexName); //create an indexSearcher for our page + IndexReader reader = IndexReader.open(FSDirectory.open(new File(indexName)), true); // only searching, so read-only=true + searcher = new IndexSearcher(reader); //create an indexSearcher for our page //NOTE: this operation is slow for large //indices (much slower than the search itself) //so you might want to keep an IndexSearcher @@ -76,7 +77,7 @@ //query string so you get the //treatment - Analyzer analyzer = new StandardAnalyzer(); //construct our usual analyzer + Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_CURRENT); //construct our usual analyzer try { QueryParser qp = new QueryParser("contents", analyzer); query = qp.parse(queryString); //parse the @@ -98,8 +99,8 @@ // searcher != null was to handle // a weird compilation bug thispage = maxpage; // default last element to maxpage - hits = searcher.search(query); // run the query - if (hits.length() == 0) { // if we got no results tell the user + hits = searcher.search(query, maxpage); // run the query + if (hits.totalHits == 0) { // if we got no results tell the user %>

I'm sorry I couldn't find what you were looking for.

<% @@ -116,15 +117,15 @@ Summary <% - if ((startindex + maxpage) > hits.length()) { - thispage = hits.length() - startindex; // set the max index to maxpage or last + if ((startindex + maxpage) > hits.totalHits) { + thispage = hits.totalHits - startindex; // set the max index to maxpage or last } // actual search result whichever is less for (int i = startindex; i < (thispage + startindex); i++) { // for each element %> <% - Document doc = hits.doc(i); //get the next document + Document doc = searcher.doc(hits.scoreDocs[i].doc); //get the next document String doctitle = doc.get("title"); //get its title String url = doc.get("path"); //get its path field if (url != null && url.startsWith("../webapps/")) { // strip off ../webapps prefix if present @@ -140,7 +141,7 @@ <% } %> -<% if ( (startindex + maxpage) < hits.length()) { //if there are more results...display +<% if ( (startindex + maxpage) < hits.totalHits) { //if there are more results...display //the more link String moreurl="results.jsp?query=" +