To Find the count in a bucket

I want to know is there a way by any chance to calculate the count of data in a bucket which contains a customer id attribute through java, instead of creating view manually with built in _count for the same…?

You can use N1QL to issue the query if you have configured query and index services.