Interface RoutingBridge<E>

  • All Superinterfaces:
    AutoCloseable

    public interface RoutingBridge<E>
    extends AutoCloseable
    An object responsible for routing an indexed entity to the correct index/shard.
    • Method Detail

      • 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 becomes ARCHIVED. If the route never changes, this method can safely delegate to route(DocumentRoutes, Object, Object, RoutingBridgeRouteContext) to return the same route.

        Warning: Reading from indexedEntity should be done with care. Any read that was not declared during binding (by declaring dependencies using RoutingBindingContext.dependencies() or (advanced use) creating an accessor using RoutingBindingContext.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 to IdentifierBridge.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 be extended 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 interface AutoCloseable