getting number of stored documents via rest api

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

getting number of stored documents via rest api

Stefan Rinner
Hi

for some tests I need to know how many documents are stored in the  
index - is there a fast & easy way to retrieve this number (instead  
of searching for "*:*" and counting the results)?
I already took a look at the stats.jsp code - but there the number of  
documents is retrieved via an api call to SolrInfoRegistry and not  
the webservice.

thanks

- stefan
Reply | Threaded
Open this post in threaded view
|

Re: getting number of stored documents via rest api

climbingrose
I think search for "*:*" is the optimal code to do it. I don't think you can
do anything faster.

On 10/11/07, Stefan Rinner <[hidden email]> wrote:

>
> Hi
>
> for some tests I need to know how many documents are stored in the
> index - is there a fast & easy way to retrieve this number (instead
> of searching for "*:*" and counting the results)?
> I already took a look at the stats.jsp code - but there the number of
> documents is retrieved via an api call to SolrInfoRegistry and not
> the webservice.
>
> thanks
>
> - stefan
>



--
Regards,

Cuong Hoang
Reply | Threaded
Open this post in threaded view
|

Re: getting number of stored documents via rest api

hossman
In reply to this post by Stefan Rinner

: there a fast & easy way to retrieve this number (instead of searching for
: "*:*" and counting the results)?

NOTE: you don't have to count the results to know the total number of
docs matching any query ... just use the numFound attribute of the
<results/> block.

: I already took a look at the stats.jsp code - but there the number of
: documents is retrieved via an api call to SolrInfoRegistry and not the
: webservice.

stats.jsp returns welformed xml (not HTML) so why not just hit that to
extract the numDocs ?



-Hoss

Reply | Threaded
Open this post in threaded view
|

Re: getting number of stored documents via rest api

hossman
In reply to this post by climbingrose

: I think search for "*:*" is the optimal code to do it. I don't think you can
: do anything faster.

FYI: getting the data from the xml returned by stats.jsp is definitely
faster in the case where you really want all docs.

if you want the total number from some other query however, don't "count"
them yourself in the client ... use <result numFound="XXX">


-Hoss

Reply | Threaded
Open this post in threaded view
|

Re: getting number of stored documents via rest api

Stefan Rinner

On Oct 10, 2007, at 6:49 PM, Chris Hostetter wrote:

>
> : I think search for "*:*" is the optimal code to do it. I don't  
> think you can
> : do anything faster.
>
> FYI: getting the data from the xml returned by stats.jsp is definitely
> faster in the case where you really want all docs.
>
> if you want the total number from some other query however, don't  
> "count"
> them yourself in the client ... use <result numFound="XXX">

for my current use-case I gonna use the numFound property because I  
can just use the solrj client for this, and don't have to add another  
http-fetching & xmlparsing method.

I overlooked the numFound property up to now but good to know.

stefan
Reply | Threaded
Open this post in threaded view
|

Re: getting number of stored documents via rest api

Walter Underwood, Netflix
This even works if you request 0 results. --wunder

On 10/11/07 1:56 AM, "Stefan Rinner" <[hidden email]> wrote:

>
> On Oct 10, 2007, at 6:49 PM, Chris Hostetter wrote:
>
>>
>> : I think search for "*:*" is the optimal code to do it. I don't
>> think you can
>> : do anything faster.
>>
>> FYI: getting the data from the xml returned by stats.jsp is definitely
>> faster in the case where you really want all docs.
>>
>> if you want the total number from some other query however, don't
>> "count"
>> them yourself in the client ... use <result numFound="XXX">
>
> for my current use-case I gonna use the numFound property because I
> can just use the solrj client for this, and don't have to add another
> http-fetching & xmlparsing method.
>
> I overlooked the numFound property up to now but good to know.
>
> stefan

Reply | Threaded
Open this post in threaded view
|

Re: getting number of stored documents via rest api

Erik Hatcher
In reply to this post by Stefan Rinner
Another route to getting the number of documents is to get it from  
the LukeRequestHandler:

        http://localhost:8983/solr/admin/luke?numTerms=0  (numTerms=0 to get  
the fastest response possible)

   Erik





On Oct 10, 2007, at 10:19 AM, Stefan Rinner wrote:

> Hi
>
> for some tests I need to know how many documents are stored in the  
> index - is there a fast & easy way to retrieve this number (instead  
> of searching for "*:*" and counting the results)?
> I already took a look at the stats.jsp code - but there the number  
> of documents is retrieved via an api call to SolrInfoRegistry and  
> not the webservice.
>
> thanks
>
> - stefan