Hi Simon,
Great piece of code indeed!
Does this limit the original results from lucene to $pp? Or is this just a
pagination logic? What I was looking for was something that would limit the
number of hits to rows-per-page (but I learn that it is not possible from
the other replies as it returns all the matching rows).
On Jan 8, 2008 4:01 AM, Simon Mundy <[EMAIL PROTECTED]> wrote:
> I've been using the SPL LimitIterator:-
>
> $index = Zend_Search_Lucene::open($this->_index);
> $query = Zend_Search_Lucene_Search_QueryParser::parse($query);
> $hits = new ArrayObject($index->find($query));
>
> if (!count($hits)) {
> return null;
> }
>
> $hits = new LimitIterator($hits->getIterator(), ($pg - 1) *
> $pp, $pp);
>
> return $hits;
>
> (Assuming you have already defined $pp as per-page and $pg as the page
> number).
>
> > Is there a way to limit the number of rows for pagination in lucene?
> > IF the file has millions of rows and returns say about 10k rows for
> > a search (all rows), the server's memory would bog down to load 10 k
> > rows into memory, right? How are others handling this situation?
>
> --
>
> Simon Mundy | Director | PEPTOLAB
>
> """ " "" """""" "" "" """"""" " "" """"" " """"" " """""" "" "
>
> 202/258 Flinders Lane | Melbourne | Victoria | Australia | 3000
> Voice +61 (0) 3 9654 4324 | Mobile 0438 046 061 | Fax +61 (0) 3 9654
> 4124
> http://www.peptolab.com
>
>