Interface SearchMapping
public interface SearchMapping
The Hibernate Search mapping between the Hibernate ORM model and the backend(s).
Provides entry points to Hibernate Search operations that are not tied to a specific ORM session.
-
Method Summary
Modifier and TypeMethodDescriptionCollection<? extends SearchIndexedEntity<?>>
backend()
default <T> T
extension
(SearchMappingExtension<T> extension) Extend the current search mapping with the given extension, resulting in an extended search mapping offering mapper-specific utilities.<E> SearchIndexedEntity<E>
indexedEntity
(Class<E> entityType) indexedEntity
(String entityName) void
Set a filter defining which types must be included/excluded when indexed within indexing plans (either automatically or manually).indexManager
(String indexName) default <T> SearchScope<T>
Create aSearchScope
limited to the given type.default <T> SearchScope<T>
Create aSearchScope
limited to entity types referenced by their name.<T> SearchScope<T>
scope
(Class<T> expectedSuperType, Collection<String> entityNames) Create aSearchScope
limited to entity types referenced by their name.<T> SearchScope<T>
scope
(Collection<? extends Class<? extends T>> types) Create aSearchScope
limited to the given types.jakarta.persistence.EntityManagerFactory
-
Method Details
-
scope
Create aSearchScope
limited to the given type.- Type Parameters:
T
- A type to include in the scope.- Parameters:
type
- A type to include in the scope.- Returns:
- The created scope.
- See Also:
-
scope
Create aSearchScope
limited to the given types.- Type Parameters:
T
- A supertype of all types to include in the scope.- Parameters:
types
- A collection of types to include in the scope.- Returns:
- The created scope.
- See Also:
-
scope
Create aSearchScope
limited to entity types referenced by their name.- Type Parameters:
T
- A supertype of all entity types to include in the scope.- Parameters:
expectedSuperType
- A supertype of all entity types to include in the scope.entityName
- An entity name. SeeEntity.name()
.- Returns:
- The created scope.
- See Also:
-
scope
Create aSearchScope
limited to entity types referenced by their name.- Type Parameters:
T
- A supertype of all entity types to include in the scope.- Parameters:
expectedSuperType
- A supertype of all entity types to include in the scope.entityNames
- A collection of entity names. SeeEntity.name()
.- Returns:
- The created scope.
- See Also:
-
toEntityManagerFactory
jakarta.persistence.EntityManagerFactory toEntityManagerFactory()- Returns:
- The underlying
EntityManagerFactory
used by thisSearchMapping
.
-
toOrmSessionFactory
SessionFactory toOrmSessionFactory()- Returns:
- The underlying
SessionFactory
used by thisSearchMapping
.
-
indexedEntity
- Type Parameters:
E
- The type of an indexed entity.- Parameters:
entityType
- The type of an indexed entity. This must be the exact type; passing the type of a mapped-superclass for example will not work.- Returns:
- A
SearchIndexedEntity
for the indexed entity with the exact given type. - Throws:
SearchException
- If the type does not match any indexed entity.
-
indexedEntity
- Parameters:
entityName
- The name of an indexed entity. SeeEntity.name()
.- Returns:
- A
SearchIndexedEntity
for the indexed entity with the given name. - Throws:
SearchException
- If the name does not match any indexed entity.
-
allIndexedEntities
Collection<? extends SearchIndexedEntity<?>> allIndexedEntities()- Returns:
- A collection containing one
SearchIndexedEntity
for each indexed entity
-
indexManager
- Parameters:
indexName
- The name of an index. SeeIndexed.index()
.- Returns:
- The index manager for the index having
indexName
as name.
-
backend
Backend backend()- Returns:
- The default backend, if any.
-
backend
- Parameters:
backendName
- The name of a backend. SeeIndexed.backend()
.- Returns:
- The backend having
backendName
as name.
-
indexingPlanFilter
Set a filter defining which types must be included/excluded when indexed within indexing plans (either automatically or manually).This does not affect indexing that does not rely on indexing plans, like the mass indexer.
By default, all indexed and contained types are included.
- Parameters:
filter
- The filter that includes/excludes types when indexed.
-
extension
Extend the current search mapping with the given extension, resulting in an extended search mapping offering mapper-specific utilities.- Type Parameters:
T
- The type of search mapping provided by the extension.- Parameters:
extension
- The extension to apply.- Returns:
- The extended search mapping.
- Throws:
SearchException
- If the extension cannot be applied (wrong underlying technology, ...).
-