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:

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

    Modifier and Type
    Method
    Description
    addMetadata(@NonNull io.fluxzero.common.api.Metadata metadata)
    Adds metadata to the index operation, merging with any previously set metadata.
    addMetadata(@NonNull Object key, Object value)
    Adds a single metadata key-value pair.
    addMetadata(@NonNull Map<String,?> values)
    Adds multiple metadata entries from a map.
    Returns the configured collection for the document.
    collection(@NonNull Object collection)
    Sets the collection into which the document should be indexed.
    Creates a deep copy of this operation, preserving all configured values.
    end()
    Returns the configured end timestamp for this operation.
    end(Instant end)
    Sets the end time for the document (e.g., used in range queries or versioning).
    id()
    Returns the configured ID of the document.
    id(@NonNull Object id)
    Sets the ID of the document to index.
    boolean
    Whether the operation is configured to only index if the document doesn't already exist.
    ifNotExists(boolean toggle)
    If set to true, only index the document if it does not already exist.
    Executes the indexing operation with a default guarantee of Guarantee.STORED.
    index(io.fluxzero.common.Guarantee guarantee)
    Executes the indexing operation with the provided guarantee.
    default void
    Executes the indexing operation with a Guarantee.NONE guarantee and does not wait for completion.
    default void
    Executes the indexing operation with Guarantee.STORED and blocks until it is completed.
    default void
    indexAndWait(io.fluxzero.common.Guarantee guarantee)
    Executes the indexing operation with the specified guarantee and blocks until it is completed.
    io.fluxzero.common.api.Metadata
    Returns the configured metadata.
    metadata(io.fluxzero.common.api.Metadata metadata)
    Replaces all metadata in this operation with the given metadata.
    period(Instant start, Instant end)
    Sets the start and end time using a time range.
    Returns the configured start timestamp for this operation.
    start(Instant start)
    Sets the start time (timestamp) for the document.
    timestamp(Instant timestamp)
    Sets both start and end time to the same instant (convenience method).
    io.fluxzero.common.api.search.BulkUpdate
    Converts the current state of the IndexOperation into a BulkUpdate instance.
    io.fluxzero.common.api.search.SerializedDocument
    Converts the current state of the IndexOperation into a Document instance.
    Returns the configured value to be indexed.
    value(Object value)
    Sets the value to be indexed.
  • 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(io.fluxzero.common.Guarantee guarantee)
      Executes the indexing operation with the specified guarantee and blocks until it is completed.
    • index

      CompletableFuture<Void> index(io.fluxzero.common.Guarantee guarantee)
      Executes the indexing operation with the provided guarantee. If the value is null, the document will be deleted.
    • 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.
    • value

      IndexOperation value(Object value)
      Sets the value to be indexed. If the value is null, the document will be deleted when index() is invoked.
    • 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 io.fluxzero.common.api.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(io.fluxzero.common.api.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.
    • collection

      Object collection()
      Returns the configured collection for the document.
    • value

      Object value()
      Returns the configured value to be indexed. If the value is null, the document will be deleted when index() is invoked.
    • metadata

      io.fluxzero.common.api.Metadata metadata()
      Returns the configured metadata.
    • ifNotExists

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

      io.fluxzero.common.api.search.SerializedDocument toDocument()
      Converts the current state of the IndexOperation into a Document instance.
    • toBulkUpdate

      io.fluxzero.common.api.search.BulkUpdate toBulkUpdate()
      Converts the current state of the IndexOperation into a BulkUpdate instance.
    • copy

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