Search code examples
solrlucene.netsolrnet

Solr query always returning first 10 rows


I have implemented Solr search in one of my .net application. Everything working fine except whenever I try to use the Solr's search functionalities, it's returning only 10 results, while I have more than 100 documents indexed. Can anyone please tell me how can I fixed this issue?

Some examples that demonstrate are:

http://117.55.242.204:8983/solr/select/?q=:&start=0&rows=10

returning 10 rows.

http://117.55.242.204:8983/solr/select/?q=.&start=20&rows=30

returning 0 rows but showing numFound 10.


Solution

  • As @Ansari stated in his answer, you need to pass the start and rows parameters to the Solr Query. In order to facilitate this using the SolrNet client, you need to set these as query options in your application. Here is the example code from the Pagination section of the Querying documentation for SolrNet.

     ISolrOperations<Product> solr = ...
     solr.Query("somequery", new QueryOptions{
       Start = 10,
       Rows = 25
     });
    

    So in this example we are assuming more than 35 results will be found and it is stating to start with the 10th item and return 25 items. So this is returning items 10-35 of the total items found in the query.