How to get all results from solr query?

SENTHIL SARAVANAN picture SENTHIL SARAVANAN · Apr 6, 2012 · Viewed 52.6k times · Source

I executed some query like "Address:Jack*". It show numFound = 5214 and display 100 documents in results page(I changed default display results from 10 to 100).

How can I get all documents.

Answer

Fermin Silva picture Fermin Silva · Apr 10, 2012

I remember myself doing &rows=2147483647

2,147,483,647 is integer's maximum value. I recall using a number bigger than that once and having a NumberFormatException because it couldn't be parsed into an int. I don't know if they use Long nowadays, but 2 billion rows is normally more than enough.

Small note:
Be careful if you are planning to do this in production. If you do a query like * : * and your index is big, you could transferring a couple of gigabytes in that query.
If you know you won't have many docs, go ahead and use integer's max value.

On the other hand, if you are doing a one-time script and just need to dump all results (for example document ID's) then this approach is valid, if you don't mind waiting 3-5 minutes for a query to return.