简体   繁体   中英

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?

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM