Find distinct Records in large data set

I have 10 Billion records. and there are only around 10 types. But the query is not showing the result. I already created an index. Is there any best way to fetch distinct data with a count.

Index : CREATE INDEX idxtype ON data(type_)

Query : select type_,count(meta().id) as counts
from data group by type_;

The index and query is right. It needs to fetch all the records and do aggregation.

If you use EE version it will be faster. https://blog.couchbase.com/understanding-index-grouping-aggregation-couchbase-n1ql-query/