gstackoverflow
gstackoverflow

Reputation: 36984

solr. what does it mean numfound?

I try to understand solr official tutorial.

I make query:

http://localhost:8983/solr/collection1/select/?indent=on&q=*&fl=name,id

and see next response:

<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">125</int>
<lst name="params">
<str name="fl">name,id</str>
<str name="indent">on</str>
<str name="q">*</str>
</lst>
</lst>
<result name="response" numFound="28" start="0">
<doc>...</doc>
<doc>...</doc>
<doc>...</doc>
<doc>...</doc>
<doc>...</doc>
<doc>...</doc>
<doc>...</doc>
<doc>...</doc>
<doc>...</doc>
<doc>...</doc>
</result>
</response>

why is numfound equals 28 but doc number is 10?

Upvotes: 2

Views: 6524

Answers (2)

Floris
Floris

Reputation: 46395

If you change your query to

http://localhost:8983/solr/collection1/select/?indent=on&q=*&fl=name,id&rows=1000000

The rows= parameter specifies the number of results to return. With a value of 1000000 you will effectively get all the docs (not just the first 10, which is the default).

If you wanted to be a bit more careful, you could read the numFound parameter, then make multiple calls to return blocks of data with

http://localhost:8983/solr/collection1/select/?indent=on&q=*&fl=name,id&start=0
http://localhost:8983/solr/collection1/select/?indent=on&q=*&fl=name,id&start=10
http://localhost:8983/solr/collection1/select/?indent=on&q=*&fl=name,id&start=20

This will return 10, 10, and 8 docs respectively.

Upvotes: 5

jro
jro

Reputation: 7480

numFound indicates the number of documents in the search index that matched your query. Solr only returns the specified number of documents in results, though. Without setting parameters, defaults are used; everything is configurable, either through the query string or in query configuration (see solrconfig.xml).

Getting to those results is through paging parameters, specifically start and rows.

Upvotes: 3

Related Questions