Get a distinct count of document types in a bucket

Hi

How can we get a distinct count of document types in a bucket when there is no primary key index on a bucket
query used : select distinct type,count(*) as type_count from buc
group by type;

Thanks

create index ix1 on buc(type);
select  type, count(1) as type_count f
rom buc
where type is not MISSING
group by type;

OR

use primary index

Thank a lot got the exact output searching for