On Wed, Oct 19, 2016 at 6:23 AM, Bastien Latard | MDPI AG <lat...@mdpi.com.invalid> wrote: > Hi everybody, > > I just had a question about facets. > *==> Is the facet run on all documents (to pre-process/cache the data) or > only on returned documents?*
Yes ;-) There are sometimes per-field data structures that are cached to support faceting. This can make the first facet request after a new searcher take longer. Unless you're using docValues, then the cost is much less. Then there are per-request data structures (like a count array) that are O(field_cardinality) and not O(matching_docs). But then for default field-cache faceting, the actual counting part is O(matching_docs). So yes, at the end of the day we only facet on the matching documents... but what the total field looks like certainly matters. -Yonik