Interface SearchIndexer


@Incubating public interface SearchIndexer
An interface for indexing entities in the context of a session.

This class is stateless: operations start executing as soon as they are submitted.

This contract is thread-safe.

  • Method Details

    • add

      default CompletionStage<?> add(Object entity)
      Add an entity to the index, assuming that the entity is absent from the index.

      Entities to reindex as a result of this operation will not be resolved.

      Shorthand for add(null, null, entity); see add(Object, DocumentRoutesDescriptor, Object).

      Parameters:
      entity - The entity to add to the index.
      Returns:
      A CompletionStage reflecting the completion state of the operation.
    • add

      default CompletionStage<?> add(Object providedId, Object entity)
      Add an entity to the index, assuming that the entity is absent from the index.

      Entities to reindex as a result of this operation will not be resolved.

      Shorthand for add(providedId, null, entity); see add(Object, DocumentRoutesDescriptor, Object).

      Parameters:
      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. If null, Hibernate Search will attempt to extract the ID from the entity.
      entity - The entity to add to the index.
      Returns:
      A CompletionStage reflecting the completion state of the operation.
    • add

      CompletionStage<?> add(Object providedId, DocumentRoutesDescriptor providedRoutes, Object entity)
      Add an entity to the index, assuming that the entity is absent from the index.

      Entities to reindex as a result of this operation will not be resolved.

      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.

      Parameters:
      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. If null, Hibernate Search will attempt to extract the ID from the entity.
      providedRoutes - The route to the current index shard. Leave null if sharding is disabled or to have Hibernate Search compute the value through the assigned RoutingBridge.
      entity - The entity to add to the index.
      Returns:
      A CompletionStage reflecting the completion state of the operation.
    • add

      CompletionStage<?> add(Class<?> entityClass, Object providedId, DocumentRoutesDescriptor providedRoutes)
      Add an entity to the index, assuming that the entity is absent from the index.

      Entities to reindex as a result of this operation will not be resolved.

      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.

      Parameters:
      entityClass - The class of the entity to add to 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.
      providedRoutes - The route to the current index shard. Leave null if sharding is disabled or if you don't use a custom RoutingBridge.
      Returns:
      A CompletionStage reflecting the completion state of the operation.
    • addOrUpdate

      default CompletionStage<?> addOrUpdate(Object entity)
      Update an entity in the index, or add it if it's absent from the index.

      Entities to reindex as a result of this operation will not be resolved.

      Shorthand for addOrUpdate(null, null, entity); see addOrUpdate(Object, DocumentRoutesDescriptor, Object).

      Parameters:
      entity - The entity to add to the index.
      Returns:
      A CompletionStage reflecting the completion state of the operation.
    • addOrUpdate

      default CompletionStage<?> addOrUpdate(Object providedId, Object entity)
      Update an entity in the index, or add it if it's absent from the index.

      Entities to reindex as a result of this operation will not be resolved.

      Shorthand for addOrUpdate(providedId, null, entity); see addOrUpdate(Object, DocumentRoutesDescriptor, Object).

      Parameters:
      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. If null, Hibernate Search will attempt to extract the ID from the entity.
      entity - The entity to update in the index.
      Returns:
      A CompletionStage reflecting the completion state of the operation.
    • addOrUpdate

      CompletionStage<?> addOrUpdate(Object providedId, DocumentRoutesDescriptor providedRoutes, Object entity)
      Update an entity in the index, or add it if it's absent from the index.

      Entities to reindex as a result of this operation will not be resolved.

      Parameters:
      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. If null, Hibernate Search will attempt to extract the ID from the entity.
      providedRoutes - The routes to the current and previous index shards. Leave null if sharding is disabled or to have Hibernate Search compute the value through the assigned RoutingBridge.
      entity - The entity to update in the index.
      Returns:
      A CompletionStage reflecting the completion state of the operation.
    • addOrUpdate

      CompletionStage<?> addOrUpdate(Class<?> entityClass, Object providedId, DocumentRoutesDescriptor providedRoutes)
      Update an entity in the index, or add it if it's absent from the index.

      Entities to reindex as a result of this operation will not be resolved.

      Parameters:
      entityClass - The class of the entity to update in 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.
      providedRoutes - The routes to the current and previous index shards. Leave null if sharding is disabled Leave null if sharding is disabled or if you don't use a custom RoutingBridge.
      Returns:
      A CompletionStage reflecting the completion state of the operation.
    • delete

      default CompletionStage<?> delete(Object entity)
      Delete an entity from the index.

      Entities to reindex as a result of this operation will not be resolved.

      Shorthand for delete(null, null, entity); see delete(Object, DocumentRoutesDescriptor, Object).

      Parameters:
      entity - The entity to add to the index.
      Returns:
      A CompletionStage reflecting the completion state of the operation.
    • delete

      default CompletionStage<?> delete(Object providedId, Object entity)
      Delete an entity from the index.

      Entities to reindex as a result of this operation will not be resolved.

      Shorthand for delete(providedId, null, entity); see delete(Object, DocumentRoutesDescriptor, Object).

      Parameters:
      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. If null, Hibernate Search will attempt to extract the ID from the entity.
      entity - The entity to delete from the index.
      Returns:
      A CompletionStage reflecting the completion state of the operation.
    • delete

      CompletionStage<?> delete(Object providedId, DocumentRoutesDescriptor providedRoutes, Object entity)
      Delete 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:
      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. If null, Hibernate Search will attempt to extract the ID from the entity.
      providedRoutes - The routes to the current and previous index shards. Leave null if sharding is disabled or to have Hibernate Search compute the value through the assigned RoutingBridge.
      entity - The entity to delete from the index.
      Returns:
      A CompletionStage reflecting the completion state of the operation.
    • delete

      CompletionStage<?> delete(Class<?> entityClass, Object providedId, DocumentRoutesDescriptor providedRoutes)
      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:
      entityClass - The class of the entity to delete from the index.
      providedId - A value to extract the document ID from.
      providedRoutes - The routes to the current and previous index shards. Leave null if sharding is disabled or to have Hibernate Search compute the value through the assigned RoutingBridge.
      Returns:
      A CompletionStage reflecting the completion state of the operation.