Package org.hibernate.search
Interface FullTextSession
- All Superinterfaces:
Serializable,org.hibernate.classic.Session,org.hibernate.Session
- All Known Implementing Classes:
FullTextSessionImpl
Extends the Hibernate
Session with fulltext search and indexing capabilities.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.hibernate.Session
org.hibernate.Session.LockRequest -
Method Summary
Modifier and TypeMethodDescriptioncreateFullTextQuery(Query luceneQuery, Class<?>... entities) Create a fulltext query on top of a native Lucene query returning the matching objects of typeentitiesand their respective subclasses.createIndexer(Class<?>... types) Creates a MassIndexer to rebuild the indexes of some or all indexed entity types.voidFlush all index changes forcing Hibernate Search to apply all changes to the index not waiting for the batch limit.<T> voidindex(T entity) Force the (re)indexing of a given managed object.<T> voidpurge(Class<T> entityType, Serializable id) Remove the entity with the typeentityTypeand the identifieridfrom the index.<T> voidRemove all entities from of particular class and all its subclasses from the index.Methods inherited from interface org.hibernate.classic.Session
createSQLQuery, createSQLQuery, delete, delete, delete, filter, filter, filter, find, find, find, iterate, iterate, iterate, save, save, saveOrUpdateCopy, saveOrUpdateCopy, saveOrUpdateCopy, saveOrUpdateCopy, update, updateMethods inherited from interface org.hibernate.Session
beginTransaction, buildLockRequest, cancelQuery, clear, close, connection, contains, createCriteria, createCriteria, createCriteria, createCriteria, createFilter, createQuery, createSQLQuery, delete, delete, disableFetchProfile, disableFilter, disconnect, doWork, enableFetchProfile, enableFilter, evict, flush, get, get, get, get, get, get, getCacheMode, getCurrentLockMode, getEnabledFilter, getEntityMode, getEntityName, getFlushMode, getIdentifier, getLobHelper, getNamedQuery, getSession, getSessionFactory, getStatistics, getTransaction, getTypeHelper, isConnected, isDefaultReadOnly, isDirty, isFetchProfileEnabled, isOpen, isReadOnly, load, load, load, load, load, load, load, lock, lock, merge, merge, persist, persist, reconnect, reconnect, refresh, refresh, refresh, replicate, replicate, save, save, saveOrUpdate, saveOrUpdate, setCacheMode, setDefaultReadOnly, setFlushMode, setReadOnly, update, update
-
Method Details
-
createFullTextQuery
Create a fulltext query on top of a native Lucene query returning the matching objects of typeentitiesand their respective subclasses.- Parameters:
luceneQuery- The native Lucene query to be run against the Lucene index.entities- List of classes for type filtering. The query result will only return entities of the specified types and their respective subtype. If no class is specified no type filtering will take place.- Returns:
- A
FullTextQuerywrapping around the native Lucene query. - Throws:
IllegalArgumentException- if entityType isnullor not a class or superclass annotated with@Indexed.
-
index
<T> void index(T entity) Force the (re)indexing of a given managed object. Indexation is batched per transaction: if a transaction is active, the operation will not affect the index at least until commit.- Parameters:
entity- The entity to index - must not benull.- Throws:
IllegalArgumentException- if entity is null or not an @Indexed entity
-
getSearchFactory
SearchFactory getSearchFactory()- Returns:
- the
SearchFactoryinstance.
-
purge
Remove the entity with the typeentityTypeand the identifieridfrom the index. Ifid == nullall indexed entities of this type and its indexed subclasses are deleted. In this case this method behaves likepurgeAll(Class).- Parameters:
entityType- The type of the entity to delete.id- The id of the entity to delete.- Throws:
IllegalArgumentException- if entityType isnullor not a class or superclass annotated with@Indexed.
-
purgeAll
Remove all entities from of particular class and all its subclasses from the index.- Parameters:
entityType- The class of the entities to remove.- Throws:
IllegalArgumentException- if entityType isnullor not a class or superclass annotated with@Indexed.
-
flushToIndexes
void flushToIndexes()Flush all index changes forcing Hibernate Search to apply all changes to the index not waiting for the batch limit. -
createIndexer
Creates a MassIndexer to rebuild the indexes of some or all indexed entity types. Instances cannot be reused.- Parameters:
types- optionally restrict the operation to selected types- Returns:
-