Mapping a single entity type to multiple indexes

Description

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 the RoutingKeyBridge, renaming it to a RoutingBridge. Its APIs would change a lot, but something like this could do:

1 2 3 4 5 6 7 8 9 10 11 12 13 public class MyRoutingBridge implements RoutingBridge { private final IndexReference indexReference1; // Obtained by the binder private final IndexReference indexReference2; // Obtained by the binder @Override public void route(Route route, String tenantIdentifier, Object entityId, String documentId, Object entity, RoutingBridgeRouteContext context) { route.index( indexReference1 ); // Only necessary if there are indexes declared by the binder route.routingKey( <compute some routing key> ); // Only necessary if the binder enabled routing keys } }

This should address:

  • 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, but let's keep it for later.

  • Most, if not all, of the use cases for Indexing Event Interceptors (). 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.

Environment

None

Status

Assignee

Unassigned

Reporter

Yoann Rodière

Labels

None

Suitable for new contributors

None

Pull Request

None

Feedback Requested

None

Components

Fix versions

Priority

Major