mfares / solrpy

Automatically exported from code.google.com/p/solrpy
0 stars 0 forks source link

paginator always runs the query twice #21

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
From the example code at the top of
http://code.google.com/p/solrpy/source/browse/trunk/solr/paginator.py, and
from reading the rest of the code, I can't see how one avoids making the
page=1 query two times. You have to pass the result into SolrPaginator for
it to get params, but then the only way to get the first page is via
paginator.page() which calls _fetch_page which calls self.conn.query. 

I was expecting page() to realize if it already has the requested page (and
perhaps for SolrPaginator to keep a buffer of the last several requested
pages).

A workaround is to get the first page like this, skipping the _fetch_page call:

            firstPage = SolrPage(paginator.result.results, page_num=1,
                                 paginator=paginator)

Original issue reported on code.google.com by drewpca on 18 Mar 2010 at 1:42