Caching in nested aggregations?

Hi devs,

I recently made a change to enable caching for nested filters in sorts. It seems like there may be a similar lack of caching in nested aggregations?

As seen here (click the link with the diff-line, and let it load for a bit):

Nested aggregations used to cache its filters in the distant past, and a conscious decision was made at the time to use Lucene's cache. However as seen here (click the link with the diff-line):

That choice to lose Lucene's cache seems to have been lost, and no cache at all is used for this computation. At this point, the NestedAggregator has access to the full SearchContext:

so would it be appropriate to delegate back to the ContextIndexSearcher here and leverage query-filter caching again?

This is wholly speculative and I've done no practical testing of this - just something I stumbled upon looking through the code that looks remarkably similar to:

so would it be appropriate to delegate back to the ContextIndexSearcher here and leverage query-filter caching again?

I don't think this would change anything because the child filter is always a simple TermQuery that matches all children of the current nested path. We don't cache TermQuery since https://github.com/elastic/elasticsearch/pull/21566 so it seems ok to me to disable caching entirely when we run this filter.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.