You are looking at documentation for an older release. Not what you want? See the current release documentation.
By default, facets are computed within the query resultset. But, you can
compute facets from all documents in the index whatever the query is,
TermsFacetBuilder facet = FacetBuilders.termsFacet("f") .field("brand") .global(true);