Interface DocumentStore

All Known Implementing Classes:
DefaultDocumentStore

public interface DocumentStore
Interface for storing, updating, and querying documents in the Fluxzero Runtime.

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 Details

    • prepareIndex

      default IndexOperation prepareIndex(@NonNull @NonNull Object object)
      Begins an index operation for the given object. Use the returned IndexOperation to set additional indexing parameters before committing.
    • index

      default CompletableFuture<Void> index(@NonNull @NonNull Object object)
      Indexes one or more objects using the default configuration. Timestamps, collection names, and IDs are inferred from annotations or fallback strategies.
    • index

      default CompletableFuture<Void> index(@NonNull @NonNull Object object, Object collection)
      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, io.fluxzero.common.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, io.fluxzero.common.api.Metadata metadata, io.fluxzero.common.Guarantee guarantee, boolean ifNotExists)
      Indexes a document with the specified guarantees, metadata, and if-not-exists condition.
    • index

      default CompletableFuture<Void> index(Collection<?> objects, Object collection)
      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, io.fluxzero.common.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, io.fluxzero.common.Guarantee guarantee, boolean ifNotExists)
      Indexes a collection of objects using functional accessors for ID and time intervals.
    • indexIfNotExists

      default CompletableFuture<Void> indexIfNotExists(Object object, Object collection)
      Indexes a document only if it is not already present in the index. The given object may be a collection of objects.
    • indexIfNotExists

      default CompletableFuture<Void> indexIfNotExists(Object object, Object id, Object collection)
      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

      default CompletableFuture<Void> bulkUpdate(Collection<? extends io.fluxzero.common.api.search.BulkUpdate> updates)
      Applies a batch of document updates, using Guarantee.STORED.
    • bulkUpdate

      CompletableFuture<Void> bulkUpdate(Collection<? extends io.fluxzero.common.api.search.BulkUpdate> updates, io.fluxzero.common.Guarantee guarantee)
      Applies a batch of document updates, using given Guarantee.
    • search

      default Search search(@NonNull @NonNull Object collection)
      Prepares a search query for one or more document collections. collections may be a list of collections. Collection names are resolved using determineCollection(Object).
    • search

      Search search(io.fluxzero.common.api.search.SearchQuery.Builder queryBuilder)
      Prepares a search query based on the specified SearchQuery.Builder.
    • hasDocument

      boolean hasDocument(Object id, Object collection)
      Checks if a document exists in the specified collection.
    • fetchDocument

      <T> Optional<T> fetchDocument(Object id, Object collection)
      Fetches a document by ID and deserializes it into the stored type.
    • fetchDocument

      <T> Optional<T> fetchDocument(Object id, Object collection, Class<T> type)
      Fetches a document by ID and deserializes it into the provided type.
    • fetchDocuments

      <T> Collection<T> fetchDocuments(Collection<?> ids, Object collection)
      Fetches a collection of documents by their IDs and deserializes them into the stored type.
    • fetchDocuments

      <T> Collection<T> fetchDocuments(Collection<?> ids, Object collection, Class<T> type)
      Fetches a collection of documents by their IDs and deserializes them into the provided type.
    • deleteDocument

      CompletableFuture<Void> deleteDocument(Object id, Object collection)
      Deletes a document from the collection.
    • deleteCollection

      CompletableFuture<Void> deleteCollection(Object collection)
      Deletes an entire collection of documents.
    • createAuditTrail

      CompletableFuture<Void> createAuditTrail(Object collection, Duration retentionTime)
      Configures Flux to use a search collection as a searchable audit trail with the given retention time.
    • determineCollection

      default String determineCollection(@NonNull @NonNull Object c)
      Resolves a given collection specifier to a collection name, using ClientUtils.determineSearchCollection(java.lang.Object).
    • getSerializer

      DocumentSerializer getSerializer()
      Retrieves the serializer used for document operations within the document store.