Class SearchIndexingPlanImpl

    • Method Detail

      • addOrUpdate

        public void addOrUpdate​(Object entity)
        Description copied from interface: SearchIndexingPlan
        Add or update a document in the index if the entity type is mapped to an index (Indexed), and re-index documents that embed this entity (through IndexedEmbedded for example).
        Specified by:
        addOrUpdate in interface SearchIndexingPlan
        Parameters:
        entity - The entity to add or update in the index.
      • delete

        public void delete​(Object entity)
        Description copied from interface: SearchIndexingPlan
        Delete the entity from the index if the entity type is mapped to an index (Indexed), and re-index documents that embed this entity (through IndexedEmbedded for example).
        Specified by:
        delete in interface SearchIndexingPlan
        Parameters:
        entity - The entity to delete from the index.
      • purge

        public void purge​(Class<?> entityClass,
                          Object providedId,
                          String providedRoutingKey)
        Description copied from interface: SearchIndexingPlan
        Delete the entity from the index.

        On contrary to SearchIndexingPlan.delete(Object), if documents embed this entity (through IndexedEmbedded for example), these documents will not be re-indexed, leaving the indexes in an inconsistent state until they are re-indexed manually.

        Specified by:
        purge in interface SearchIndexingPlan
        Parameters:
        entityClass - The class of the entity to delete from the index.
        providedId - A value to extract the document ID from. Generally the expected value is the entity ID, but a different value may be expected depending on the mapping.
        providedRoutingKey - The routing key to route the purge request to the appropriate index shard. Leave null if sharding is disabled or does not rely on custom routing keys.
      • purge

        public void purge​(String entityName,
                          Object providedId,
                          String providedRoutingKey)
        Description copied from interface: SearchIndexingPlan
        Delete the entity from the index.

        On contrary to SearchIndexingPlan.delete(Object), if documents embed this entity (through IndexedEmbedded for example), these documents will not be re-indexed, leaving the indexes in an inconsistent state until they are re-indexed manually.

        Specified by:
        purge in interface SearchIndexingPlan
        Parameters:
        entityName - An entity name. See Entity.name().
        providedId - A value to extract the document ID from. Generally the expected value is the entity ID, but a different value may be expected depending on the mapping.
        providedRoutingKey - The routing key to route the purge request to the appropriate index shard. Leave null if sharding is disabled or does not rely on custom routing keys.
      • process

        public void process()
        Description copied from interface: SearchIndexingPlan
        Extract all data from objects passed to the indexing plan so far, creates documents to be indexed and put them into an internal buffer, without writing them to the indexes.

        Calling this method is optional: the SearchIndexingPlan.execute() method or the automatic write on transaction commit will perform the extraction as necessary.

        However, calling this method can be useful before a session is cleared if indexing listeners are disabled: it will make sure the data lost when clearing the session will no longer be necessary for indexing.

        Caution: calling this method repeatedly without a call to SearchIndexingPlan.execute() will add more and more data to an internal document buffer, which may lead to an OutOfMemoryError. Use with caution in batch processes.

        Specified by:
        process in interface SearchIndexingPlan
      • execute

        public void execute()
        Description copied from interface: SearchIndexingPlan
        Write all pending changes to the index now, without waiting for a Hibernate ORM flush event or transaction commit.

        If a transaction is active and is ultimately rolled back, the written changes will not be rolled back, causing indexes to become out of sync with the database. Thus, calling this method should generally be avoided, and relying on automatic write on transaction commit should be preferred.

        Specified by:
        execute in interface SearchIndexingPlan