Interface PojoIndexingPlan<R>
-
public interface PojoIndexingPlan<R>
An interface for indexing entities in the context of a session in a POJO mapper.This class is stateful: it queues operations internally to apply them at a later time.
When
process()
is called, the entities will be processed and index documents will be built and stored in an internal buffer.When
executeAndReport()
is called, the operations will be actually sent to the index.Note that
executeAndReport()
will implicitly trigger processing of documents that weren't processed yet, if any, so callingprocess()
is not necessary if you callexecuteAndReport()
just next.Implementations may not be thread-safe.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
add(PojoRawTypeIdentifier<?> typeIdentifier, Object providedId, String providedRoutingKey, Object entity)
Add an entity to the index, assuming that the entity is absent from the index.void
addOrUpdate(PojoRawTypeIdentifier<?> typeIdentifier, Object providedId, String providedRoutingKey, Object entity)
Update an entity in the index, or add it if it's absent from the index.void
addOrUpdate(PojoRawTypeIdentifier<?> typeIdentifier, Object providedId, String providedRoutingKey, Object entity, String... dirtyPaths)
Update an entity in the index, or add it if it's absent from the index, but try to avoid reindexing if the given dirty paths are known not to impact the indexed form of that entity.void
delete(PojoRawTypeIdentifier<?> typeIdentifier, Object providedId, String providedRoutingKey, Object entity)
Delete an entity from the index.void
discard()
Discard all plans of indexing.void
discardNotProcessed()
Discard all plans of indexing, except for parts that were alreadyprocessed
.CompletableFuture<IndexIndexingPlanExecutionReport<R>>
executeAndReport()
Write all pending changes to the index now, without waiting for a Hibernate ORM flush event or transaction commit, and clear the plan so that it can be re-used.void
process()
Extract all data from objects passed to the indexing plan so far, create documents to be indexed and put them into an internal buffer, without writing them to the indexes.void
purge(PojoRawTypeIdentifier<?> typeIdentifier, Object providedId, String providedRoutingKey)
Purge an entity from the index.
-
-
-
Method Detail
-
add
void add(PojoRawTypeIdentifier<?> typeIdentifier, Object providedId, String providedRoutingKey, Object entity)
Add an entity to the index, assuming that the entity is absent from the index.Note: depending on the backend, this may lead to errors or duplicate entries in the index if the entity was actually already present in the index before this call. When in doubt, you should rather use
addOrUpdate(PojoRawTypeIdentifier, Object, String, Object)
.- Parameters:
typeIdentifier
- The identifier of the entity type.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. Ifnull
, Hibernate Search will attempt to extract the ID from the entity.providedRoutingKey
- The routing key to route the add request to the appropriate index shard. Leavenull
if sharding is disabled or to have Hibernate Search compute the value through the assignedRoutingBridge
.entity
- The entity to add to the index.
-
addOrUpdate
void addOrUpdate(PojoRawTypeIdentifier<?> typeIdentifier, Object providedId, String providedRoutingKey, Object entity)
Update an entity in the index, or add it if it's absent from the index.- Parameters:
typeIdentifier
- The identifier of the entity type.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. Ifnull
, Hibernate Search will attempt to extract the ID from the entity.providedRoutingKey
- The routing key to route the addOrUpdate request to the appropriate index shard. Leavenull
if sharding is disabled or to have Hibernate Search compute the value through the assignedRoutingBridge
.entity
- The entity to update in the index.
-
addOrUpdate
void addOrUpdate(PojoRawTypeIdentifier<?> typeIdentifier, Object providedId, String providedRoutingKey, Object entity, String... dirtyPaths)
Update an entity in the index, or add it if it's absent from the index, but try to avoid reindexing if the given dirty paths are known not to impact the indexed form of that entity.- Parameters:
typeIdentifier
- The identifier of the entity type.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. Ifnull
, Hibernate Search will attempt to extract the ID from the entity.providedRoutingKey
- The routing key to route the addOrUpdate request to the appropriate index shard. Leavenull
if sharding is disabled or to have Hibernate Search compute the value through the assignedRoutingBridge
.entity
- The entity to update in the index.dirtyPaths
- The paths to consider dirty, formatted using the dot-notation ("directEntityProperty.nestedPropery").
-
delete
void delete(PojoRawTypeIdentifier<?> typeIdentifier, Object providedId, String providedRoutingKey, Object entity)
Delete an entity from the index.No effect on the index if the entity is not in the index.
- Parameters:
typeIdentifier
- The identifier of the entity type.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. Ifnull
, Hibernate Search will attempt to extract the ID from the entity.providedRoutingKey
- The routing key to route the delete request to the appropriate index shard. Leavenull
if sharding is disabled or to have Hibernate Search compute the value through the assignedRoutingBridge
.entity
- The entity to delete from the index.
-
purge
void purge(PojoRawTypeIdentifier<?> typeIdentifier, Object providedId, String providedRoutingKey)
Purge an entity from the index.Entities to reindex as a result of this operation will not be resolved.
No effect on the index if the entity is not in the index.
- Parameters:
typeIdentifier
- The identifier of the entity type.providedId
- A value to extract the document ID from.providedRoutingKey
- The routing key to route the purge request to the appropriate index shard. Leavenull
if sharding is disabled or if you don't use a customRoutingBridge
.
-
process
void process()
Extract all data from objects passed to the indexing plan so far, create documents to be indexed and put them into an internal buffer, without writing them to the indexes.In particular, ensure that all data is extracted from the POJOs and converted to the backend-specific format.
Calling this method is optional: the
executeAndReport()
method will perform the processing if necessary.
-
executeAndReport
CompletableFuture<IndexIndexingPlanExecutionReport<R>> executeAndReport()
Write all pending changes to the index now, without waiting for a Hibernate ORM flush event or transaction commit, and clear the plan so that it can be re-used.- Returns:
- A
CompletableFuture
that will be completed with an execution report when all the works are complete.
-
discard
void discard()
Discard all plans of indexing.
-
discardNotProcessed
void discardNotProcessed()
Discard all plans of indexing, except for parts that were alreadyprocessed
.
-
-