Move search query loading options to a better place in the search query DSL

Description

Right now, if you want to set loading options when building a search query, it has to be the very first thing you do:

As you can see, it's quite weird when specifying the result type explicitly.
Ideally we'd want this:

... but because we want to support backend-specific options in .asProjection(), it's not possible (at least not unless we define one API for every mapper/backend combination).

Maybe we could expose something like this?

Note this could make much more sense when combined with HSEARCH-3628, where we need to expose per-type options. We'd end up with this:

Or, more probably (to be truly mapper-agnostic, and avoid the dubious assumption that mapped types are Java types):

We may want to also allow an optional, non-lambda syntax:

Environment

None

Status

Assignee

Yoann Rodière

Reporter

Yoann Rodière

Labels

None

Suitable for new contributors

None

Pull Request

None

Feedback Requested

None

Components

Fix versions

Priority

Major
Configure