JAVA API for FACETS

Is Facets the way to get the total number of hits per data? If so then do we have an example to implementing facets with JAVA API? All I need is a count on the terms.
Thanks