Yoann Rodière (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *updated* an issue
Hibernate Search (
https://hibernate.atlassian.net/browse/HSEARCH?atlOrigin=eyJpIjoiZjkzZmYw...
) / Improvement (
https://hibernate.atlassian.net/browse/HSEARCH-3683?atlOrigin=eyJpIjoiZjk...
) HSEARCH-3683 (
https://hibernate.atlassian.net/browse/HSEARCH-3683?atlOrigin=eyJpIjoiZjk...
) Mapping a single entity type to multiple indexes (
https://hibernate.atlassian.net/browse/HSEARCH-3683?atlOrigin=eyJpIjoiZjk...
)
Change By: Yoann Rodière (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
Introduce a way to map a single entity type to multiple indexes:
* on bootstrap, user code will provide a list of index names that this entity type will be
mapped to (instead of just one usually).
* at runtime, each entity to index will be inspected by user code upon indexing, and
routed to the correct index.
For example, we could repurpose use the {{ RoutingKeyBridge IndexedConfigurer }} ,
renaming it to a on bootstrap and the {{RoutingBridge}} at runtime; both were introduced
in HSEARCH-3108. Its APIs would change a lot, but something like this could do:
{code}
public class MyRoutingBridge implements RoutingBridge <MyEntity> {
private final IndexReference indexReference1; // Obtained by the binder configurer
private final IndexReference indexReference2; // Obtained by the binder configurer
@Override
public void route( Route route DocumentRoutes routes ,
String tenantIdentifier, Object entityId, String documentId, Object MyEntity entity,
RoutingBridgeRouteContext context) {
route routes. index addRoute ( indexReference1 ) ; // Only The argument is only necessary
if there are indexes declared by the binder
route.routingKey( <compute some routing key> ); // Only necessary if the binder
enabled user wishes to use custom routing keys
}
}
{code}
This should address most, if not all, of the use cases for Indexing Event Interceptors
(HSEARCH-3108). These interceptors are mainly used to prevent indexing of entities that
are in a certain state. We could provide a way for users to route an entity to
"nowhere" ({{route.discard()}}?), meaning it will be removed from all indexes
and will not be added anywhere.
Note that initially, we'll force all indexes to have the exact same mapping. We'll
allow each index to have a different mapping in HSEARCH-3971, and then we'll have
addressed part of the use cases mentioned in HSEARCH-3313: essentially all the use cases
except those where the list of indexes is not known in advance. Even that one could be
covered eventually, in theory but that'll have to be handled in HSEARCH-3313 (if
ever).
(
https://hibernate.atlassian.net/browse/HSEARCH-3683#add-comment?atlOrigin...
) Add Comment (
https://hibernate.atlassian.net/browse/HSEARCH-3683#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#100140- sha1:5beb332 )