Composite projections

Description

Follow-up on HSEARCH‌-3222 .

The idea would be to provide a type-safe solution to building objects that encompass multiple projections, for example a "Color" object that requires a projection on the "red", "green" and "blue" fields.

We would offer the ability to build such a projection:

  • Though the projection DSL: {‌{target.projection().composite()….}‌}

  • When calling .asProjections() with a multiple parameters in {‌{HibernateOrmSearchQueryResultDefinitionContext}‌} plus a BiFunction/TriFunction/etc. acting as a “hit transformer”: this would allow to create a type-safe query, returning results with a known type even when using projections.

In the future (not in this ticket), this will be particularly useful when combined with multi-valued nested object fields, allowing to get a List<Color> from a projection for example.

Draft of the APIs: https://github.com/yrodiere/hibernate-search/tree/projections-syntax-attempt2 , https://github.com/yrodiere/hibernate-search/commit/5f9f56f587d3e44344b773bdefeb70c8fedf1be1

We decided to give up on the fluid API for composite projections, for two reasons:

  1. We decided to remove the fluid APIs for predicates and sorts, so let's be consistent

  2. Having one interface per number of parameters is complex to implement (or at least very redundant), and it also makes implementing extensions much more complex, because we'll have to implement each interface in each backend...

Environment

None

Status

Assignee

Guillaume Smet

Reporter

Yoann Rodière

Labels

None

Suitable for new contributors

None

Feedback Requested

None

Components

Fix versions

Priority

Major
Configure