Interface RoutingBridge<E>
- All Superinterfaces:
AutoCloseable
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
close()
Closes any resource before the routing bridge is discarded.void
previousRoutes
(DocumentRoutes routes, Object entityIdentifier, E indexedEntity, RoutingBridgeRouteContext context) Defines the potential previous routes for an indexed entity.void
route
(DocumentRoutes routes, Object entityIdentifier, E indexedEntity, RoutingBridgeRouteContext context) Routes an indexed entity.
-
Method Details
-
route
void route(DocumentRoutes routes, Object entityIdentifier, E indexedEntity, RoutingBridgeRouteContext context) Routes an indexed entity.Defining the route should be done by calling methods on the
route
parameter.Warning: Reading from
indexedEntity
should be done with care. Any read that was not declared duringbinding
(by declaring dependencies usingRoutingBindingContext.dependencies()
or (advanced use) creating an accessor usingRoutingBindingContext.bridgedElement()
) may lead to out-of-sync indexes, because Hibernate Search will consider the read property irrelevant to indexing and will not reindex entities when that property changes.Warning: If the route of a given entity with a given id can change (e.g. an entity is indexed when its status is
PUBLISHED
, but is no longer indexed when it becomesARCHIVED
), you must also implementpreviousRoutes(DocumentRoutes, Object, Object, RoutingBridgeRouteContext)
to return all the possible previous routes so that Hibernate Search can clean up previously indexed documents.- Parameters:
routes
- The routes to follow when indexing the given entity, to be configured by this bridge.entityIdentifier
- The value of the POJO property used to generate the document identifier, i.e. the same value that is passed toIdentifierBridge.toDocumentIdentifier(Object, org.hibernate.search.mapper.pojo.bridge.runtime.IdentifierBridgeToDocumentIdentifierContext)
.indexedEntity
- The indexed entity that should be routed by this bridge.context
- A context that can beextended
to a more useful type, giving access to such things as a Hibernate ORM Session (if using the Hibernate ORM mapper).
-
previousRoutes
void previousRoutes(DocumentRoutes routes, Object entityIdentifier, E indexedEntity, RoutingBridgeRouteContext context) Defines the potential previous routes for an indexed entity.Defining the routes should be done by calling methods on the
route
parameter. Hibernate Search will follow these routes to delete the previous versions of a document.Implementing this method is only necessary if the route used to index a document can change, for example if an entity is indexed when its status is
PUBLISHED
, but is no longer indexed when it becomesARCHIVED
. If the route never changes, this method can safely delegate toroute(DocumentRoutes, Object, Object, RoutingBridgeRouteContext)
to return the same route.Warning: Reading from
indexedEntity
should be done with care. Any read that was not declared duringbinding
(by declaring dependencies usingRoutingBindingContext.dependencies()
or (advanced use) creating an accessor usingRoutingBindingContext.bridgedElement()
) may lead to out-of-sync indexes, because Hibernate Search will consider the read property irrelevant to indexing and will not reindex entities when that property changes.- Parameters:
routes
- The routes that were (potentially) used to index the given entity, to be configured by this bridge.entityIdentifier
- The value of the POJO property used to generate the document identifier, i.e. the same value that is passed toIdentifierBridge.toDocumentIdentifier(Object, org.hibernate.search.mapper.pojo.bridge.runtime.IdentifierBridgeToDocumentIdentifierContext)
.indexedEntity
- The indexed entity that should be routed by this bridge.context
- A context that can beextended
to a more useful type, giving access to such things as a Hibernate ORM Session (if using the Hibernate ORM mapper).
-
close
default void close()Closes any resource before the routing bridge is discarded.- Specified by:
close
in interfaceAutoCloseable
-