Class SearchIndexingPlanImpl
- All Implemented Interfaces:
SearchIndexingPlan
-
Constructor Summary
ConstructorsConstructorDescriptionSearchIndexingPlanImpl(SearchIndexingPlanTypeContextProvider typeContextProvider, SearchIndexingPlanSessionContext sessionContext) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddOrUpdate(Object entity) 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 (throughIndexedEmbeddedfor example).voidDelete the entity from the index if the entity type is mapped to an index (Indexed), and re-index documents that embed this entity (throughIndexedEmbeddedfor example).voidexecute()Write all pending changes to the index now, without waiting for a Hibernate ORM flush event or transaction commit.voidprocess()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.voidDelete the entity from the index.voidDelete the entity from the index.
-
Constructor Details
-
SearchIndexingPlanImpl
public SearchIndexingPlanImpl(SearchIndexingPlanTypeContextProvider typeContextProvider, SearchIndexingPlanSessionContext sessionContext)
-
-
Method Details
-
addOrUpdate
Description copied from interface:SearchIndexingPlanAdd 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 (throughIndexedEmbeddedfor example).- Specified by:
addOrUpdatein interfaceSearchIndexingPlan- Parameters:
entity- The entity to add or update in the index.
-
delete
Description copied from interface:SearchIndexingPlanDelete the entity from the index if the entity type is mapped to an index (Indexed), and re-index documents that embed this entity (throughIndexedEmbeddedfor example).- Specified by:
deletein interfaceSearchIndexingPlan- Parameters:
entity- The entity to delete from the index.
-
purge
Description copied from interface:SearchIndexingPlanDelete the entity from the index.On contrary to
SearchIndexingPlan.delete(Object), if documents embed this entity (throughIndexedEmbeddedfor example), these documents will not be re-indexed, leaving the indexes in an inconsistent state until they are re-indexed manually.- Specified by:
purgein interfaceSearchIndexingPlan- 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. Leavenullif sharding is disabled or does not rely on custom routing keys.
-
purge
Description copied from interface:SearchIndexingPlanDelete the entity from the index.On contrary to
SearchIndexingPlan.delete(Object), if documents embed this entity (throughIndexedEmbeddedfor example), these documents will not be re-indexed, leaving the indexes in an inconsistent state until they are re-indexed manually.- Specified by:
purgein interfaceSearchIndexingPlan- Parameters:
entityName- An entity name. SeeEntity.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. Leavenullif sharding is disabled or does not rely on custom routing keys.
-
process
public void process()Description copied from interface:SearchIndexingPlanExtract 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 listenersare 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 anOutOfMemoryError. Use with caution in batch processes.- Specified by:
processin interfaceSearchIndexingPlan
-
execute
public void execute()Description copied from interface:SearchIndexingPlanWrite 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:
executein interfaceSearchIndexingPlan
-