If you have the jq command, that will be cleaner than using tr.

Also, you can get the number of documents with a query for *:* instead of using 
the admin API.

This same question was asked on Sep. 19th. This was my answer then.

====
Do a search. The URL will looks something like this:

  /solr/core-name/select?q=*:*&rows=0&wt=json

That will return something like this:

  
{"responseHeader":{"status":0,"QTime":1},"response":{"numFound":287176,"start":0,"docs":[]}}

Filter that response through this:

  jq .response.numFound

And you’ll get the number of documents in the core.
====

wunder
Walter Underwood
wun...@wunderwood.org
http://observer.wunderwood.org/  (my blog)


> On Oct 5, 2016, at 12:22 PM, Alan Woodward <a...@flax.co.uk> wrote:
> 
> tr -d ‘0-9’ is removing all numbers from the line, which I’m guessing is the 
> opposite of what you want?
> 
> Alan Woodward
> www.flax.co.uk
> 
> 
>> On 5 Oct 2016, at 20:17, KRIS MUSSHORN <mussho...@comcast.net> wrote:
>> 
>> Will someone please tell me why this stores the text "numDocs" instead of 
>> returning the number of docs in the core? 
>> 
>> #!/bin/bash 
>> DOC_COUNT=`wget -O- -q 
>> $SOLR_HOST'admin/cores?action=STATUS&core='$SOLR_CORE_NAME'&wt=json&indent=true'
>>  | grep numDocs | tr -d '0-9'` 
>> 
>> TIA 
>> 
>> Kris 
> 

Reply via email to