Restricting the terms returned in facets

Hi,

I am interested in computing the terms count across all the documents, but
want to return the terms which are present in a particular field of the
documents matching with filter/query.

The documentation talks about various methods like restricting the
documents considered while computing the results, which is quite different
than what I am looking for.

A use case can be like getting the counts of all the terms present in a
particular filtered document to calculate their idf(or such aggregate
statistics) of individual terms present in some field.

How can this be achieved?

--