We're updating the issue view to help you get more done. 

Introduce a projection DSL


The idea would be to allow to create SearchProjection<T> objects from a SearchTarget, and use these objects when creating a query: .asProjections( projectionObject1, projectionObject2, ...).

This would allow three things:

  • Implementation of parameterized projections, where naming the projection is not enough, and we need to pass parameters to it. See for example the spatial distance projections, where we need to pass a latitude and longitude:

  • Enabling and disabling bridges in projections; see

  • Type-safe projections, i.e. passing typed references to the asProjections() methods, and get a SearchQuery<Pair<T, U>>, or SearchQuery<Triplet<T, U, V>>, and so on depending on the number of parameters. This would obviously only be possible for a small number of parameters (say, up to 5), because we would have to declare and implement one asProjections() method for each possible number of parameters. Note that, in order to allow that, we should at the very least make asProjections set the query type to SearchQuery<? extends List<?>> instead of the current SearchQuery<List<?>>.

See also

An example of APIs can be found here: https://github.com/hibernate/hibernate-search-6-poc/commit/85edb83d1d248dba0514a78177b1c19761f67646

Let's discuss the APIs again, though, since they are not very consistent with what we offer for predicates, and more importantly for sorts. => Done

New draft: https://github.com/yrodiere/hibernate-search/tree/projections-syntax-attempt2 , https://github.com/yrodiere/hibernate-search/commit/5f9f56f587d3e44344b773bdefeb70c8fedf1be1

NOTE: support for composite projections was moved to





Guillaume Smet


Yoann Rodière



Suitable for new contributors


Feedback Requested


Fix versions