Lucene projections on fields in nested documents should limit children collection to the top docs

Description

Currently we have something like this in LuceneSearcherImpl:

And findChildQuery does this:

This code doesn't take the top docs into account, so we will always retrieve the children for all documents, even if the query was limited to the 20 top documents.
This may add up and lead to poor performance in large indexes, where we would retrieve the children of millions of documents.

The current version of findChildQuery is fine for sorts and aggregations, where we need to inspect all documents, but we should definitely add another version that only returns the IDs of a specific subset of documents, for use in

Environment

None

Assignee

Yoann Rodière

Reporter

Yoann Rodière

Labels

None

Suitable for new contributors

None

Feedback Requested

None

Components

Fix versions

Priority

Major
Configure