[hibernate-issues] [JIRA] (HSEARCH-3683) Mapping a single entity type to multiple indexes

Yoann Rodière (JIRA) jira at hibernate.atlassian.net
Thu Jul 30 10:36:32 EDT 2020


Yoann Rodière ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A58fa1ced-171a-4c00-97e8-5d70d442cc4b ) *updated* an issue

Hibernate Search ( https://hibernate.atlassian.net/browse/HSEARCH?atlOrigin=eyJpIjoiZjkzZmYwNTY0Y2Y5NDI1ZTk3ZTlmYjgwZTYyMDVmOTIiLCJwIjoiaiJ9 ) / Improvement ( https://hibernate.atlassian.net/browse/HSEARCH-3683?atlOrigin=eyJpIjoiZjkzZmYwNTY0Y2Y5NDI1ZTk3ZTlmYjgwZTYyMDVmOTIiLCJwIjoiaiJ9 ) HSEARCH-3683 ( https://hibernate.atlassian.net/browse/HSEARCH-3683?atlOrigin=eyJpIjoiZjkzZmYwNTY0Y2Y5NDI1ZTk3ZTlmYjgwZTYyMDVmOTIiLCJwIjoiaiJ9 ) Mapping a single entity type to multiple indexes ( https://hibernate.atlassian.net/browse/HSEARCH-3683?atlOrigin=eyJpIjoiZjkzZmYwNTY0Y2Y5NDI1ZTk3ZTlmYjgwZTYyMDVmOTIiLCJwIjoiaiJ9 )

Change By: Yoann Rodière ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A58fa1ced-171a-4c00-97e8-5d70d442cc4b )

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=eyJpIjoiZjkzZmYwNTY0Y2Y5NDI1ZTk3ZTlmYjgwZTYyMDVmOTIiLCJwIjoiaiJ9 ) Add Comment ( https://hibernate.atlassian.net/browse/HSEARCH-3683#add-comment?atlOrigin=eyJpIjoiZjkzZmYwNTY0Y2Y5NDI1ZTk3ZTlmYjgwZTYyMDVmOTIiLCJwIjoiaiJ9 )

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.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100140- sha1:5beb332 )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200730/8fc0d7f3/attachment.html 


More information about the hibernate-issues mailing list