0

Using SOLR, I have indexed device specific events. Each event containins a MAC address (deviceID) and a date. I would like to compute the distinct number of devices per day. I have tried the following code based on the Stats component but it seems that the Distinct part does not work.

.../solr/collectionVRtft_shard1_replica1/
query?q=":"
facet=true&
facet.field=date
&facet.stat=stbCount:unique(deviceID)

SQL equivalent code would be:
SELECT date, count(DISTINCT deviceID)
FROM...
GROUP BY date;

Thank you!

marlieg
  • 449
  • 2
  • 5
  • 16
  • Does you date field include time information? You could perhaps convert this to date only in the DISTINCT clause – Grantly Oct 23 '14 at 13:31
  • Sorry for the typo mistakes :) I have updated the code. Date field includes dates in this format "YYYYmmDD" – marlieg Oct 23 '14 at 13:52
  • Your new edits make more sense :) What error msg/output do you get? – Grantly Oct 23 '14 at 16:04
  • I do not get any error. It is just that my counts are not unique. "facet_counts": { "facet_queries": {}, "facet_fields": { "date": [ "20141023", 308, "20141022", 103, "20000101", 0 ] } – marlieg Oct 23 '14 at 16:07
  • Did you check this? http://stackoverflow.com/questions/2814000/how-to-select-distinct-field-values-using-solr – Grantly Oct 23 '14 at 18:36

0 Answers0