Interface IndexOperation

All Known Implementing Classes:
DefaultIndexOperation

public interface IndexOperation
Builder-style interface for indexing documents into the DocumentStore.

This interface allows step-by-step construction of an indexing operation, including setting document identifiers, time ranges, collections, metadata, and whether to only index if the document doesn't already exist. Once configured, the operation can be triggered using various convenience methods (e.g. index(), indexAndForget(), or indexAndWait()).

To begin building an index operation, use:

     FluxCapacitor.get().documentStore().prepareIndex(myObject)
         .id("myId")
         .collection("MyCollection")
         .timestamp(Instant.now())
         .addMetadata("source", "api")
         .indexAndWait();
 
See Also:
  • Method Details

    • index

      default CompletableFuture<Void> index()
      Executes the indexing operation with a default guarantee of Guarantee.STORED.
    • indexAndForget

      default void indexAndForget()
      Executes the indexing operation with a Guarantee.NONE guarantee and does not wait for completion.
    • indexAndWait

      default void indexAndWait()
      Executes the indexing operation with Guarantee.STORED and blocks until it is completed.
    • indexAndWait

      default void indexAndWait(Guarantee guarantee)
      Executes the indexing operation with the specified guarantee and blocks until it is completed.
    • index

      CompletableFuture<Void> index(Guarantee guarantee)
      Executes the indexing operation with the provided guarantee.
    • id

      IndexOperation id(@NonNull @NonNull Object id)
      Sets the ID of the document to index.
    • collection

      IndexOperation collection(@NonNull @NonNull Object collection)
      Sets the collection into which the document should be indexed.
    • start

      IndexOperation start(Instant start)
      Sets the start time (timestamp) for the document.
    • end

      Sets the end time for the document (e.g., used in range queries or versioning).
    • timestamp

      default IndexOperation timestamp(Instant timestamp)
      Sets both start and end time to the same instant (convenience method).
    • period

      default IndexOperation period(Instant start, Instant end)
      Sets the start and end time using a time range.
    • addMetadata

      default IndexOperation addMetadata(@NonNull @NonNull Metadata metadata)
      Adds metadata to the index operation, merging with any previously set metadata.
    • addMetadata

      default IndexOperation addMetadata(@NonNull @NonNull Object key, Object value)
      Adds a single metadata key-value pair.
    • addMetadata

      default IndexOperation addMetadata(@NonNull @NonNull Map<String,?> values)
      Adds multiple metadata entries from a map.
    • metadata

      IndexOperation metadata(Metadata metadata)
      Replaces all metadata in this operation with the given metadata.
    • ifNotExists

      IndexOperation ifNotExists(boolean toggle)
      If set to true, only index the document if it does not already exist.
    • start

      Instant start()
      Returns the configured start timestamp for this operation.
    • end

      Instant end()
      Returns the configured end timestamp for this operation.
    • id

      Object id()
      Returns the configured ID of the document.
    • metadata

      Metadata metadata()
      Returns the configured metadata.
    • ifNotExists

      boolean ifNotExists()
      Whether the operation is configured to only index if the document doesn't already exist.
    • copy

      Creates a deep copy of this operation, preserving all configured values.