Solr query always returns first 10 rows

I implemented Solr search in one of my .net applications. Everything works fine, except when I try to use the Solr search functions, it only returns 10 results, while I have more than 100 documents indexed. Can someone please tell me how can I fix this problem?

The following are some examples:

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

returns 10 rows.

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

returns 0 rows, but shows numFound 10.

+4
source share
3 answers

As @Ansari said in his answer, you need to pass the start and rows parameters to the Solr request. To facilitate this use of the SolrNet client, you need to set them as query parameters in your application. Here is a sample 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 assume that more than 35 results will be found, and he declares that he will start from the 10th point and return 25 elements. Thus, it returns items 10-35 from all items found in the query.

+2
source

Here you need to pay attention to two variables: start and rows .

In the first case, it returns only 10 documents, because rows is 10. In the second case, it tries to return documents from 21 to 30 ( start is 20, and rows is 10), but there are only 10 corresponding documents so that it returns zero.

If you want all your documents to be returned, set rows to a high value, such as 1000 or 10000, or the number of documents in your index. If you are not using paging, make sure start set to 0.

+3
source

I agree with Ansari's answer, however I have one comment. You can't just set strings for some indecently large number, because pagination is a natural and intuitive way to use solr.

If it was a reasonable work with productivity or even a logical operation, then there would be an easy way to return all the documents. The fact that such a thing does not exist means that a short iterative pagination rather than returning a large dataset is the way to go.

+1
source

Source: https://habr.com/ru/post/1411226/


All Articles