There's a perfectly good answer for how to get a unique count in solr from their website, http://yonik.com/solr-count-distinct/, and from this SO answer: How to select distinct field values using Solr?
My issue is that I do not understand how to translate this cURL syntax into PHP, which is what I'm coding in.
The official example seems easy enough to follow from a what's going on in this code perspective:
$ curl http://localhost:8983/solr/techproducts/query -d '
q=*:*&
json.facet={
x : "unique(manu_exact)" // manu_exact is the manufacturer indexed as a single string
}'
However, I'm only familiar with two ways of submitting a solr query to my server using PHP. The first, using a direct URL:
$url = "localhost:8983/solr/asdf/select?q=*:*";
$Q = curl_init();
curl_setopt($Q, CURLOPT_RETURNTRANSFER, true);
curl_setopt($Q, CURLOPT_URL, $url);
$rawData = curl_exec($Q);
$data = json_decode($rawData,true);
or through posting the values:
$url = "localhost:8983/solr/asdf/select";
$solr_q = "q=date_range:[2016+TO+*]&fq=title:manager&wt=json&indent=true";
$ch = curl_init();
curl_setopt($ch, CURLOPT_POSTFIELDS, $solr_q);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
$rawData = curl_exec($ch);
$json = json_decode($rawData,true);
I'm running solr 5.4.1, so I know I have the ability to do json facets, but I have no idea how to make the request outside of the official example using command line curl. How do I utilize this json.facet
in the same manner that I'm currently utilizing solr in PHP?