Interface DocumentStore
- All Known Implementing Classes:
DefaultDocumentStore
public interface DocumentStore
Interface for storing, updating, and querying documents in the Flux Capacitor platform.
This API allows objects to be indexed into searchable document collections, with support for metadata, timestamps,
audit trails, conditional indexing, and deletion. It also supports typed or faceted full-text search queries via
Search
.
The interface provides various convenience methods for indexing single objects, collections, and for bulk update operations. Indexing behavior can be configured by annotating model classes or customizing indexing strategies manually.
Note that collection names are resolved using determineCollection(Object)
in many of this API's methods.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault CompletableFuture
<Void> bulkUpdate
(Collection<? extends BulkUpdate> updates) Applies a batch of document updates, usingGuarantee.STORED
.bulkUpdate
(Collection<? extends BulkUpdate> updates, Guarantee guarantee) Applies a batch of document updates, using givenGuarantee
.createAuditTrail
(Object collection, Duration retentionTime) Configures Flux to use a search collection as a searchable audit trail with the given retention time.deleteCollection
(Object collection) Deletes an entire collection of documents.deleteDocument
(Object id, Object collection) Deletes a document from the collection.default String
determineCollection
(@NonNull Object c) Resolves a given collection specifier to a collection name, usingClientUtils.determineSearchCollection(java.lang.Object)
.<T> Optional
<T> fetchDocument
(Object id, Object collection) Fetches a document by ID and deserializes it into the stored type.<T> Optional
<T> fetchDocument
(Object id, Object collection, Class<T> type) Fetches a document by ID and deserializes it into the provided type.Retrieves the serializer used for document operations within the document store.boolean
hasDocument
(Object id, Object collection) Checks if a document exists in the specified collection.index
(@NotNull Object object, Object id, Object collection, Instant begin, Instant end, Metadata metadata, Guarantee guarantee, boolean ifNotExists) Indexes a document with the specified guarantees, metadata, and if-not-exists condition.default CompletableFuture
<Void> index
(@NotNull Object object, Object id, Object collection, Instant begin, Instant end, Guarantee guarantee, boolean ifNotExists) Indexes a document with the specified guarantees, metadata, and if-not-exists condition.default CompletableFuture
<Void> Indexes one or more objects using the default configuration.default CompletableFuture
<Void> Indexes one or more objects into the specified collection.default CompletableFuture
<Void> Indexes a single object with an explicitly provided ID and collection.default CompletableFuture
<Void> Indexes a single object at a specific timestamp.default CompletableFuture
<Void> Indexes a single object with a specific start and end time.default CompletableFuture
<Void> index
(Collection<?> objects, Object collection) Indexes a collection of objects into a named collection.default CompletableFuture
<Void> index
(Collection<?> objects, Object collection, String idPath, String timestampPath) Indexes a collection of objects using property paths for ID and timestamps.default CompletableFuture
<Void> Indexes a collection of objects using property paths for ID, start, and end timestamps.index
(Collection<?> objects, Object collection, String idPath, String beginPath, String endPath, Guarantee guarantee, boolean ifNotExists) Indexes a collection of objects using functional accessors for ID and time intervals.default <T> CompletableFuture
<Void> index
(Collection<? extends T> objects, Object collection, Function<? super T, ?> idFunction) Indexes a collection of objects using a function to extract the object ID.default <T> CompletableFuture
<Void> index
(Collection<? extends T> objects, Object collection, Function<? super T, ?> idFunction, Function<? super T, Instant> timestampFunction) Indexes a collection of objects using property paths for ID, start, and end timestamps.default <T> CompletableFuture
<Void> index
(Collection<? extends T> objects, Object collection, Function<? super T, ?> idFunction, Function<? super T, Instant> beginFunction, Function<? super T, Instant> endFunction) Indexes a collection of objects using property paths for ID, start, and end timestamps.<T> CompletableFuture
<Void> index
(Collection<? extends T> objects, Object collection, Function<? super T, ?> idFunction, Function<? super T, Instant> beginFunction, Function<? super T, Instant> endFunction, Guarantee guarantee, boolean ifNotExists) Indexes a collection of objects using functional accessors for ID and time intervals.default CompletableFuture
<Void> indexIfNotExists
(Object object, Object collection) Indexes a document only if it is not already present in the index.default CompletableFuture
<Void> indexIfNotExists
(Object object, Object id, Object collection) Indexes a document only if it is not already present in the index.default CompletableFuture
<Void> indexIfNotExists
(Object object, Object id, Object collection, Instant timestamp) Indexes a document only if it is not already present in the index.default CompletableFuture
<Void> Indexes a document only if it is not already present in the index.default <T> CompletableFuture
<Void> indexIfNotExists
(Collection<? extends T> objects, Object collection) Indexes documents only if there are not already present in the index.default <T> CompletableFuture
<Void> indexIfNotExists
(Collection<? extends T> objects, Object collection, String idPath, String timestampPath) Indexes documents only if there are not already present in the index.default <T> CompletableFuture
<Void> indexIfNotExists
(Collection<? extends T> objects, Object collection, String idPath, String beginPath, String endPath) Indexes documents only if there are not already present in the index.default <T> CompletableFuture
<Void> indexIfNotExists
(Collection<? extends T> objects, Object collection, Function<? super T, ?> idFunction) Indexes documents only if there are not already present in the index.default <T> CompletableFuture
<Void> indexIfNotExists
(Collection<? extends T> objects, Object collection, Function<? super T, ?> idFunction, Function<? super T, Instant> timestampFunction) Indexes documents only if there are not already present in the index.default <T> CompletableFuture
<Void> indexIfNotExists
(Collection<? extends T> objects, Object collection, Function<? super T, ?> idFunction, Function<? super T, Instant> beginFunction, Function<? super T, Instant> endFunction) Indexes documents only if there are not already present in the index.default IndexOperation
prepareIndex
(@NonNull Object object) Begins an index operation for the given object.search
(SearchQuery.Builder queryBuilder) Prepares a search query based on the specifiedSearchQuery.Builder
.default Search
Prepares a search query for one or more document collections.
-
Method Details
-
prepareIndex
Begins an index operation for the given object. Use the returnedIndexOperation
to set additional indexing parameters before committing. -
index
Indexes one or more objects using the default configuration. Timestamps, collection names, and IDs are inferred from annotations or fallback strategies. -
index
Indexes one or more objects into the specified collection. -
index
default CompletableFuture<Void> index(@NonNull @NonNull Object object, Object id, Object collection) Indexes a single object with an explicitly provided ID and collection. -
index
default CompletableFuture<Void> index(@NonNull @NonNull Object object, Object id, Object collection, Instant timestamp) Indexes a single object at a specific timestamp.The same value is used as both start and end time of the document.
-
index
default CompletableFuture<Void> index(@NonNull @NonNull Object object, Object id, Object collection, Instant begin, Instant end) Indexes a single object with a specific start and end time. -
index
default CompletableFuture<Void> index(@NotNull @NotNull Object object, Object id, Object collection, Instant begin, Instant end, Guarantee guarantee, boolean ifNotExists) Indexes a document with the specified guarantees, metadata, and if-not-exists condition. -
index
CompletableFuture<Void> index(@NotNull @NotNull Object object, Object id, Object collection, Instant begin, Instant end, Metadata metadata, Guarantee guarantee, boolean ifNotExists) Indexes a document with the specified guarantees, metadata, and if-not-exists condition. -
index
Indexes a collection of objects into a named collection. -
index
default <T> CompletableFuture<Void> index(Collection<? extends T> objects, Object collection, Function<? super T, ?> idFunction) Indexes a collection of objects using a function to extract the object ID. -
index
default CompletableFuture<Void> index(Collection<?> objects, Object collection, String idPath, String timestampPath) Indexes a collection of objects using property paths for ID and timestamps. -
index
default CompletableFuture<Void> index(Collection<?> objects, Object collection, String idPath, String beginPath, String endPath) Indexes a collection of objects using property paths for ID, start, and end timestamps. -
index
CompletableFuture<Void> index(Collection<?> objects, Object collection, String idPath, String beginPath, String endPath, Guarantee guarantee, boolean ifNotExists) Indexes a collection of objects using functional accessors for ID and time intervals. -
index
default <T> CompletableFuture<Void> index(Collection<? extends T> objects, Object collection, Function<? super T, ?> idFunction, Function<? super T, Instant> timestampFunction) Indexes a collection of objects using property paths for ID, start, and end timestamps. -
index
default <T> CompletableFuture<Void> index(Collection<? extends T> objects, Object collection, Function<? super T, ?> idFunction, Function<? super T, Instant> beginFunction, Function<? super T, Instant> endFunction) Indexes a collection of objects using property paths for ID, start, and end timestamps. -
index
<T> CompletableFuture<Void> index(Collection<? extends T> objects, Object collection, Function<? super T, ?> idFunction, Function<? super T, Instant> beginFunction, Function<? super T, Instant> endFunction, Guarantee guarantee, boolean ifNotExists) Indexes a collection of objects using functional accessors for ID and time intervals. -
indexIfNotExists
Indexes a document only if it is not already present in the index. The given object may be a collection of objects. -
indexIfNotExists
Indexes a document only if it is not already present in the index. -
indexIfNotExists
default CompletableFuture<Void> indexIfNotExists(Object object, Object id, Object collection, Instant timestamp) Indexes a document only if it is not already present in the index. -
indexIfNotExists
default CompletableFuture<Void> indexIfNotExists(Object object, Object id, Object collection, Instant begin, Instant end) Indexes a document only if it is not already present in the index. -
indexIfNotExists
default <T> CompletableFuture<Void> indexIfNotExists(Collection<? extends T> objects, Object collection) Indexes documents only if there are not already present in the index. -
indexIfNotExists
default <T> CompletableFuture<Void> indexIfNotExists(Collection<? extends T> objects, Object collection, Function<? super T, ?> idFunction) Indexes documents only if there are not already present in the index. -
indexIfNotExists
default <T> CompletableFuture<Void> indexIfNotExists(Collection<? extends T> objects, Object collection, String idPath, String timestampPath) Indexes documents only if there are not already present in the index. -
indexIfNotExists
default <T> CompletableFuture<Void> indexIfNotExists(Collection<? extends T> objects, Object collection, String idPath, String beginPath, String endPath) Indexes documents only if there are not already present in the index. -
indexIfNotExists
default <T> CompletableFuture<Void> indexIfNotExists(Collection<? extends T> objects, Object collection, Function<? super T, ?> idFunction, Function<? super T, Instant> timestampFunction) Indexes documents only if there are not already present in the index. -
indexIfNotExists
default <T> CompletableFuture<Void> indexIfNotExists(Collection<? extends T> objects, Object collection, Function<? super T, ?> idFunction, Function<? super T, Instant> beginFunction, Function<? super T, Instant> endFunction) Indexes documents only if there are not already present in the index. -
bulkUpdate
Applies a batch of document updates, usingGuarantee.STORED
. -
bulkUpdate
Applies a batch of document updates, using givenGuarantee
. -
search
Prepares a search query for one or more document collections.collections
may be alist
of collections. Collection names are resolved usingdetermineCollection(Object)
. -
search
Prepares a search query based on the specifiedSearchQuery.Builder
. -
hasDocument
Checks if a document exists in the specified collection. -
fetchDocument
Fetches a document by ID and deserializes it into the stored type. -
fetchDocument
Fetches a document by ID and deserializes it into the provided type. -
deleteDocument
Deletes a document from the collection. -
deleteCollection
Deletes an entire collection of documents. -
createAuditTrail
Configures Flux to use a search collection as a searchable audit trail with the given retention time. -
determineCollection
Resolves a given collection specifier to a collection name, usingClientUtils.determineSearchCollection(java.lang.Object)
. -
getSerializer
DocumentSerializer getSerializer()Retrieves the serializer used for document operations within the document store.
-