Marko Bekhta (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate Search (
https://hibernate.atlassian.net/browse/HSEARCH?atlOrigin=eyJpIjoiZDc1YTRh...
) / New Feature (
https://hibernate.atlassian.net/browse/HSEARCH-4838?atlOrigin=eyJpIjoiZDc...
) HSEARCH-4838 (
https://hibernate.atlassian.net/browse/HSEARCH-4838?atlOrigin=eyJpIjoiZDc...
) Conisder adding `fromRoot` projection (
https://hibernate.atlassian.net/browse/HSEARCH-4838?atlOrigin=eyJpIjoiZDc...
)
Issue Type: New Feature Assignee: Unassigned Created: 20/Apr/2023 05:19 AM Fix Versions:
7.0-backlog Priority: Major Reporter: Marko Bekhta (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
From the original ticket (
https://hibernate.atlassian.net/browse/HSEARCH-4827 ):
*If* we feel that it’s useful to allow it, but only when the user is explicitly requesting
it, we can expose something like the (currently SPI) rootContext method:
org.hibernate.search.engine.search.projection.spi.SearchProjectionBuilderFactory#rootContext.
We’d end up with something like this:
List<MyBookProjection> hits = searchSession.search( Book.class )
.select( f -> f.composite()
.from(
f.field( "title", String.class ),
f.object( "authors" )
.from(
f.fromRoot( f.id() ), // We EXPLICITLY tell HSearch
to use the root ID
f.field( "authors.firstName",
String.class ),
f.field( "authors.lastName", String.class
)
)
.as( MyBookProjection.Author::new )
.multi()
)
.as( MyBookProjection::new ) )
.where( f -> f.matchAll() )
.fetchHits( 20 );
Note there’s a similarity between this fromRoot projection and Elasticsearch's concept
of reverse_nested aggregations:
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-ag....
Maybe we could introduce that kind of things later, but that’s definitely beyond the scope
of this issue.
(
https://hibernate.atlassian.net/browse/HSEARCH-4838#add-comment?atlOrigin...
) Add Comment (
https://hibernate.atlassian.net/browse/HSEARCH-4838#add-comment?atlOrigin...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100222- sha1:57eb20e )