My first Scout plugin!
I'm digging Scout so far, and it has almost all the plugins I would want already in their plugin directory. However, I did want to add in a Solr "healthcheck", since we've noticed some oddities with our search index.
Here is a quick-and-dirty way to get the number of results based on an empty search (i.e. the entire index) for a single Solr core on localhost. Maybe this will help somebody else out there. I suppose it could be paramterized with hostnames, search strings, etc... and it wouldn't be that hard either from what it looks like.
class SolrResultCount < Scout::Plugin needs "rubygems" needs "json" needs "net/http" def build_report url = "http://localhost:8983/solr/select?q=&rows=3&fl=bundle&wt=json" r = Net::HTTP.get_response(URI.parse(url)) parsed = JSON.parse(r.body) report(:results=>parsed["response"]["numFound"]) end end