lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Walter Underwood <walter.r.underw...@gmail.com>
Subject Re: bash to get doc count
Date Wed, 05 Oct 2016 19:39:59 GMT
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
wunder@wunderwood.org
http://observer.wunderwood.org/  (my blog)


> On Oct 5, 2016, at 12:22 PM, Alan Woodward <alan@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 <musshorns@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 
> 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message