Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 2203 invoked from network); 24 Jul 2005 16:33:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 24 Jul 2005 16:33:56 -0000 Received: (qmail 18197 invoked by uid 500); 24 Jul 2005 16:33:54 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 17264 invoked by uid 500); 24 Jul 2005 16:33:52 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 17251 invoked by uid 99); 24 Jul 2005 16:33:51 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 24 Jul 2005 09:33:51 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: local policy) Received: from [216.68.218.166] (HELO home.simpleobjects.com) (216.68.218.166) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 24 Jul 2005 09:33:45 -0700 Received: from graphite (graphite.intranet [192.168.2.2]) by home.simpleobjects.com (Postfix) with ESMTP id E927033C3B for ; Sun, 24 Jul 2005 12:33:46 -0400 (EDT) From: "Tony Schwartz" To: Subject: RE: Implementing paging functionality in lucene Date: Sun, 24 Jul 2005 12:33:46 -0400 Message-ID: <004901c5906d$7720cb00$0202a8c0@graphite> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.6626 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 In-Reply-To: <001601c5906b$a5dd95b0$5d1afea9@dsil.danlawinc.com> Importance: Normal X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Don't do that. Don't use a filter for paging. Just use the Hits object = and get from it only the records applicable for that page. Tony Schwartz tony@simpleobjects.com "We're going to need a lot more cowbell." -----Original Message----- From: Harini Raghavan [mailto:harini.raghavan@insideview.com]=20 Sent: Sunday, July 24, 2005 12:21 PM To: java-user@lucene.apache.org Subject: Implementing paging functionality in lucene Hi All, I am trying to add paging functionality while using lucene search. I = have created a PageFilter what takes in the current page num and the number = of records as input and invoking the IndexSearcher passing the a Boolean = Query object and the PageFilter. The search returns around 1000 records when invoked without the PageFilter, but with the PageFilter, it returns only = 6 records. I did some debugging and realised that the in the org.apache.lucene.search.IndexSearcher.search method, the = bitset.get(doc) is returning false for all the other documents and so they are not added to = the results. Has someone implemented Paging using filters or tell me if I am missing something here? Here is the code : public List searchDocuments(DocumentSearchCriteria searchCriteria) = throws ApplicationException { List results =3D new ArrayList(); String indexLoc =3D luceneConfig.getIndexDir(); Directory fsDir =3D getIndexDirectory(indexLoc, false); IndexSearcher searcher =3D getIndexSearcher(fsDir); Query query =3D indexSearchUtil.getSearchQuery(searchCriteria); try { Hits hits =3D searcher.search(query, new PageFilter(0,20)); logger.info("Found " + hits.length() + " document(s) that matched query '" + query + "':"); results =3D indexSearchUtil.populateDocumentInfoView(hits, results); } catch(Exception e) { logger.error("Exception occurred in searchDocuments()"); } return results; } Here is the PageFilter : public class PageFilter extends Filter { private int start; private int end; public PageFilter(int pageNum, int pageSize) { start =3D pageNum * pageSize; end =3D (pageNum+1) * pageSize; } public BitSet bits(IndexReader reader) throws IOException { BitSet result =3D new BitSet(reader.maxDoc()); for(int i=3Dstart; (i