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: HSEARCH-3190 * Enabling and disabling bridges in projections; see HSEARCH-3257 * 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 HSEARCH-2265
-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
We decided to give up on the fluid API NOTE: support for composite projections , for two reasons:
# We decided was moved to remove the fluid APIs for predicates and sorts, so let's be consistent # 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... HSEARCH-3390 |
|