Interface SearchWorkspace
-
public interface SearchWorkspace
The entry point for explicit index operations.A
SearchWorkspace
targets a pre-defined set of indexed types (and their indexes), filtered to only affect a single tenant, if relevant.While
automatic indexing
generally takes care of indexing entities as they are persisted/deleted in the database, there are cases where massive operations must be applied to the index, such as completely purging the index. This is where theSearchWorkspace
comes in.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
flush()
Flush to disk the changes to indexes that were not committed yet.CompletionStage<?>
flushAsync()
Asynchronous version offlush()
, returning as soon as the operation is queued.void
mergeSegments()
Merge all segments of the indexes targeted by this workspace into a single one.CompletionStage<?>
mergeSegmentsAsync()
Asynchronous version ofmergeSegments()
, returning as soon as the operation is queued.void
purge()
Delete all documents from indexes targeted by this workspace.void
purge(Set<String> routingKeys)
Delete documents from indexes targeted by this workspace that were indexed with any of the given routing keys.CompletionStage<?>
purgeAsync()
Asynchronous version ofpurge()
, returning as soon as the operation is queued.CompletionStage<?>
purgeAsync(Set<String> routingKeys)
Asynchronous version ofpurge(Set)
, returning as soon as the operation is queued.void
refresh()
Refresh the indexes so that all changes executed so far will be visible in search queries.CompletionStage<?>
refreshAsync()
Asynchronous version ofrefresh()
, returning as soon as the operation is queued.
-
-
-
Method Detail
-
purge
void purge()
Delete all documents from indexes targeted by this workspace.With multi-tenancy enabled, only documents of the current tenant will be removed: the tenant that was targeted by the session from where this workspace originated.
-
purgeAsync
CompletionStage<?> purgeAsync()
Asynchronous version ofpurge()
, returning as soon as the operation is queued.- Returns:
- A
CompletionStage
reflecting the completion state of the operation. - See Also:
purge()
-
purge
void purge(Set<String> routingKeys)
Delete documents from indexes targeted by this workspace that were indexed with any of the given routing keys.With multi-tenancy enabled, only documents of the current tenant will be removed: the tenant that was targeted by the session from where this workspace originated.
- Parameters:
routingKeys
- The set of routing keys. If non-empty, only documents that were indexed with these routing keys will be deleted. If empty, documents will be deleted regardless of their routing key.
-
purgeAsync
CompletionStage<?> purgeAsync(Set<String> routingKeys)
Asynchronous version ofpurge(Set)
, returning as soon as the operation is queued.- Parameters:
routingKeys
- The set of routing keys.- Returns:
- A
CompletionStage
reflecting the completion state of the operation. - See Also:
purge(Set)
-
flush
void flush()
Flush to disk the changes to indexes that were not committed yet. In the case of backends with a transaction log (Elasticsearch), also apply operations from the transaction log that were not applied yet.This is generally not useful as Hibernate Search commits changes automatically. Only to be used by experts fully aware of the implications.
Note that some operations may still be waiting in a queue when
flush()
is called, in particular operations queued as part of automatic indexing before a transaction is committed. These operations will not be applied immediately just because a call toflush()
is issued: the "flush" here is a very low-level operation handled by the backend.
-
flushAsync
CompletionStage<?> flushAsync()
Asynchronous version offlush()
, returning as soon as the operation is queued.- Returns:
- A
CompletionStage
reflecting the completion state of the operation. - See Also:
flush()
-
refresh
void refresh()
Refresh the indexes so that all changes executed so far will be visible in search queries.This is generally not useful as indexes are refreshed automatically, either after every change (default for the Lucene backend) or periodically (default for the Elasticsearch backend, possible for the Lucene backend by setting a refresh interval). Only to be used by experts fully aware of the implications.
Note that some operations may still be waiting in a queue when
refresh()
is called, in particular operations queued as part of automatic indexing before a transaction is committed. These operations will not be applied immediately just because a call torefresh()
is issued: the "refresh" here is a very low-level operation handled by the backend.
-
refreshAsync
CompletionStage<?> refreshAsync()
Asynchronous version ofrefresh()
, returning as soon as the operation is queued.- Returns:
- A
CompletionStage
reflecting the completion state of the operation. - See Also:
refresh()
-
mergeSegments
void mergeSegments()
Merge all segments of the indexes targeted by this workspace into a single one.Note this operation may affect performance positively as well as negatively. See the reference documentation for more information.
-
mergeSegmentsAsync
CompletionStage<?> mergeSegmentsAsync()
Asynchronous version ofmergeSegments()
, returning as soon as the operation is queued.Note this operation may affect performance positively as well as negatively. See the reference documentation for more information.
- Returns:
- A
CompletionStage
reflecting the completion state of the operation. - See Also:
mergeSegments()
-
-