count distinct in solr without command line cURL count distinct in solr without command line cURL curl curl

count distinct in solr without command line cURL


As always - right after you make a post on SO you find the answer. If someone could still shed some light on maybe a better way for me to be doing this I would be very grateful - but this technically works as a direct URL:

http://localhost:8983/solr/asdf/select?q=*:*&json.facet.x="unique(field)"&wt=json&indent=true&rows=0

or using the syntax I used in the OP:

...$url    = "http://localhost:8983/solr/asdf/select";  $post   = "q=*:*&json.facet.x=\"unique(field)\"&rows=0&wt=json&indent=true";...

The things I was missing is that:

  1. I had to name the json facet, (&json.facet.x= instead of &json.facet= and the { } characters need to be replaced with quotation marks " " in order for the query to work as a URL or a POST request.

I really hope this helps someone as it has been frustrating me to no end for about a month now.....