Class DefaultIndexOperation

java.lang.Object
io.fluxzero.sdk.persisting.search.DefaultIndexOperation
All Implemented Interfaces:
IndexOperation

public class DefaultIndexOperation extends Object implements IndexOperation
Default implementation of the IndexOperation interface.

This class provides a mutable, builder-style implementation for preparing and executing document indexing operations using a DocumentStore.

Instances of this class are typically created by calling DocumentStore.prepareIndex(Object). Upon construction, the document ID, collection name, and timestamps are automatically extracted from the object's class using reflection.

See Also:
  • Constructor Details

    • DefaultIndexOperation

      public DefaultIndexOperation()
  • Method Details

    • prepare

      public static DefaultIndexOperation prepare(DocumentStore documentStore, @NonNull @NonNull Object object)
      Prepare a new DefaultIndexOperation instance for managing document indexing.
      Parameters:
      documentStore - the DocumentStore used to store and manage the index operations
      object - the object to be indexed, which will be analyzed and converted for storage
      Returns:
      an index operation initialized for the given object
    • prepare

      public static DefaultIndexOperation prepare(DocumentStore documentStore, Object object, @NonNull @NonNull Object collection, String idPath, String beginPath, String endPath)
      Prepares a new DefaultIndexOperation instance to manage document indexing with specified path mappings.
      Parameters:
      documentStore - the DocumentStore used to store and manage the index operations
      object - the object to be indexed, which will be analyzed and converted for storage
      collection - the collection in which the object resides
      idPath - the path used to determine the unique ID of the document; if null or blank, a new ID is generated
      beginPath - the path specifying the beginning timestamp of the document; ignored if null
      endPath - the path specifying the ending timestamp of the document; defaults to corresponding begin timestamp if null
      Returns:
      an initialized DefaultIndexOperation for managing document indexing
    • prepare

      public static DefaultIndexOperation prepare(DocumentStore documentStore, Object object, @NonNull @NonNull Object collection, Function<Object,?> idFunction, Function<Object,Instant> beginFunction, Function<Object,Instant> endFunction)
      Prepares a new DefaultIndexOperation instance for managing document indexing with specified functions for extracting key properties from the object.
      Parameters:
      documentStore - the DocumentStore used to manage and store index operations
      object - the object to be indexed, which will be analyzed and converted for storage
      collection - the collection in which the object resides
      idFunction - a Function to extract the unique ID of the document from the object
      beginFunction - a Function to determine the beginning timestamp of the document from the object
      endFunction - a Function to determine the ending timestamp of the document from the object
      Returns:
      a fully initialized DefaultIndexOperation for the specified object and collection with the metadata and timestamps appropriately set
    • prepareDelete

      public static DefaultIndexOperation prepareDelete(DocumentStore documentStore, @NonNull @NonNull Object collection, @NonNull @NonNull Object id)
      Prepares a new DefaultIndexOperation instance for deleting a document from the specified collection in the DocumentStore.
      Parameters:
      documentStore - the DocumentStore used to store and manage the index operations
      collection - the collection from which the document should be deleted
      id - the unique identifier of the document to be deleted
      Returns:
      a DefaultIndexOperation instance configured for the delete operation
    • index

      public CompletableFuture<Void> index(Guarantee guarantee)
      Description copied from interface: IndexOperation
      Executes the indexing operation with the provided guarantee. If the value is null, the document will be deleted.
      Specified by:
      index in interface IndexOperation
    • toDocument

      public SerializedDocument toDocument()
      Description copied from interface: IndexOperation
      Converts the current state of the IndexOperation into a Document instance.
      Specified by:
      toDocument in interface IndexOperation
    • toBulkUpdate

      public BulkUpdate toBulkUpdate()
      Description copied from interface: IndexOperation
      Converts the current state of the IndexOperation into a BulkUpdate instance.
      Specified by:
      toBulkUpdate in interface IndexOperation
    • copy

      public IndexOperation copy()
      Description copied from interface: IndexOperation
      Creates a deep copy of this operation, preserving all configured values.
      Specified by:
      copy in interface IndexOperation