cytsunny
cytsunny

Reputation: 5030

How to get total number of document in Solr without returning everything?

One way to know how many document are there in total is:

http://localhost:8983/solr/demo/select?indent=on&q=*:*&wt=json

The response->numFound will be the number of document. However, this will return all the data in Solr too. This will be very slow if I have many document or if I have some very big document. Is there quicker way to do counting? Something like select count(*) from table in SQL?

P.S. I am using PHP to connect to Solr.

Upvotes: 3

Views: 3304

Answers (1)

Binoy Dalal
Binoy Dalal

Reputation: 896

Just append &rows=0 to your query.

Upvotes: 10

Related Questions