You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by "Peter W." <pe...@marketingbrokers.com> on 2006/12/28 06:02:35 UTC

Paging Lucene Results

Hello,

I'm trying to iterate or page through Lucene document hits results.
Before reinventing this, is there an existing solution out there or  
in Solr?

Thanks in advance,

Peter

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Paging Lucene Results

Posted by "Peter W." <pe...@marketingbrokers.com>.
Thanks.

When you are trying to determine how many items to show on a results  
page
and you have:

1. number of hits you want to display (hpp)
2. total hitcount returned by Lucene from a query (hc)
3. the results page you are currently on (ipg)

there's some math involved and I was looking for that formula.

Here's  one possible solution...

    private static int decide_hitsper(int hpp,int hc,int ipg,String use)
       {
       int ri=0;
       if(use.indexOf("l") ! 
=-1)                                                         // LOW(MIN)
          { // LOW
          ri=((ipg*hpp)-(hpp-1));
          } // if
        
else                                                                     
           // HIGH(MAX)
          { // MAX
          if(hc>hpp)
             {
             if((ipg*hpp) <= hc)
                ri=(ipg*hpp);
              
else                                                                     
     // few results
                ri=hc;
             } // inner if
          else
             ri=hc;
          } // else
       return ri;
       }

Also, is there an available sample of using TopDocs .search()?

Peter W.



On Dec 27, 2006, at 10:33 PM, Erik Hatcher wrote:

>
> On Dec 28, 2006, at 12:02 AM, Peter W. wrote:
>> I'm trying to iterate or page through Lucene document hits results.
>> Before reinventing this, is there an existing solution out there  
>> or in Solr?
>
> There really isn't much wheel to reinvent... you can "page" through  
> Hits by simply starting at any point and going forward however many  
> documents you want per page.  You could also use TopDocs  
> returning .search() methods, which is what I think Solr does.   
> Again, not much to it - pick a starting point, and go from there.

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Paging Lucene Results

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Dec 28, 2006, at 12:02 AM, Peter W. wrote:
> I'm trying to iterate or page through Lucene document hits results.
> Before reinventing this, is there an existing solution out there or  
> in Solr?

There really isn't much wheel to reinvent... you can "page" through  
Hits by simply starting at any point and going forward however many  
documents you want per page.  You could also use TopDocs  
returning .search() methods, which is what I think Solr does.  Again,  
not much to it - pick a starting point, and go from there.

	Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org