Performance of multiple facets with query filters

Hi,
Is it faster to make one query with filters and Y facets, instead of
making Y queries with filters and one facet ?
ElasticSearch will iterate on all filtered documents, and apply the
facet algorithms on each of them ? I guess it won't reiterate on all
filtered documents for each facet ? Seems obvious, but I just need to
be 100% sure.
And what happens if the facets have filters ? Do ES merge the query
and facet filters and make one query ? So it would need to do that for
each facets ?
Thanks.

I'd imagine that the only way to be 100% sure is to try it :slight_smile:

If you're not yet at the point where you have data to run it on, then
you may well be optimising prematurely. It could be fast enough either
way.

Still, I agree that it would be interesting to know more about how the
algorithms work (unfortunately I don't know either).

Cheers,
Chris

On Tue, Jun 28, 2011 at 7:33 PM, Nicolas Fouché
nicolas.fouche@gmail.com wrote:

Hi,
Is it faster to make one query with filters and Y facets, instead of
making Y queries with filters and one facet ?
Elasticsearch will iterate on all filtered documents, and apply the
facet algorithms on each of them ? I guess it won't reiterate on all
filtered documents for each facet ? Seems obvious, but I just need to
be 100% sure.
And what happens if the facets have filters ? Do ES merge the query
and facet filters and make one query ? So it would need to do that for
each facets ?
Thanks.

Hi,

Facets are calculated as a one pass on the query (putting aside global facets here), even if they have facet filters (which just filter out docs from the facet calculation).

-shay.banon

On Tuesday, June 28, 2011 at 4:08 PM, Chris Berkhout wrote:

I'd imagine that the only way to be 100% sure is to try it :slight_smile:

If you're not yet at the point where you have data to run it on, then
you may well be optimising prematurely. It could be fast enough either
way.

Still, I agree that it would be interesting to know more about how the
algorithms work (unfortunately I don't know either).

Cheers,
Chris

On Tue, Jun 28, 2011 at 7:33 PM, Nicolas Fouché
<nicolas.fouche@gmail.com (mailto:nicolas.fouche@gmail.com)> wrote:

Hi,
Is it faster to make one query with filters and Y facets, instead of
making Y queries with filters and one facet ?
Elasticsearch will iterate on all filtered documents, and apply the
facet algorithms on each of them ? I guess it won't reiterate on all
filtered documents for each facet ? Seems obvious, but I just need to
be 100% sure.
And what happens if the facets have filters ? Do ES merge the query
and facet filters and make one query ? So it would need to do that for
each facets ?
Thanks.