>
> final static int MAX_ROWS = 100;
> int start = 0;
> query.setRows(MAX_ROWS);
> while (true)
> {
>   QueryResponse resp = solrChunkServer.query(query);
>   SolrDocumentList docs = resp.getResults();
>   if (docs.size() == 0)
>     break;
>   ....
>  start += MAX_ROWS;
>  query.setStart(start);
> }
>
Yes. It will work as you think. But are you sure that you want to do this?
How many documents do you have in the index? If the number is in an
acceptable range, why not simply do a query.setRows(Integer.MAX_VALUE) once?


Cheers
Avlesh

On Tue, Nov 3, 2009 at 6:19 AM, Paul Tomblin <ptomb...@xcski.com> wrote:

> If I want to do a query and only return X number of rows at a time,
> but I want to keep querying until I get all the row, how do I do that?
>  Can I just keep advancing query.setStart(...) and then checking if
> server.query(query) returns any rows?  Or is there a better way?
>
> Here's what I'm thinking
>
> final static int MAX_ROWS = 100;
> int start = 0;
> query.setRows(MAX_ROWS);
> while (true)
> {
>   QueryResponse resp = solrChunkServer.query(query);
>   SolrDocumentList docs = resp.getResults();
>   if (docs.size() == 0)
>     break;
>   ....
>  start += MAX_ROWS;
>  query.setStart(start);
> }
>
>
>
> --
> http://www.linkedin.com/in/paultomblin
> http://careers.stackoverflow.com/ptomblin
>

Reply via email to