This won't actually give you the number of distinct facet values, but will give you the number of documents matching your conditions. It's more equivalent to SQL without the "distinct".
There is no way in Solr 1.4 to get the number of distinct facet values. I am not sure about the new features in trunk. ________________________________________ From: Peter Karich [peat...@yahoo.de] Sent: Wednesday, December 22, 2010 6:10 AM To: solr-user@lucene.apache.org Subject: Re: solr equiv of : SELECT count(distinct(field)) FROM index WHERE length(field) > 0 AND other_criteria facets=true&facet.field=field // SELECT count(distinct(field)) &fq=field:[* TO *] // WHERE length(field) > 0 &q=other_criteriaA&fq=other_criteriaB// AND other_criteria advantage: you can look into several fields at one time when adding another facet.field disadvantage: you get the counts splitted by the values of that field fix this via field collapsing / results grouping http://wiki.apache.org/solr/FieldCollapsing or use deduplication: http://wiki.apache.org/solr/Deduplication Regards, Peter. > Hi, > > Is there a way with faceting or field collapsing to do the SQL equivalent of > > SELECT count(distinct(field)) FROM index WHERE length(field) > 0 AND > other_criteria > > i.e. I'm only interested in the total count not the individual records > and counts. > > Cheers, > Dan -- http://jetwick.com open twitter search