Class DefaultIndexOperation
java.lang.Object
io.fluxzero.sdk.persisting.search.DefaultIndexOperation
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncopy()Creates a deep copy of this operation, preserving all configured values.Executes the indexing operation with the provided guarantee.static DefaultIndexOperationprepare(DocumentStore documentStore, @NonNull Object object) Prepare a newDefaultIndexOperationinstance for managing document indexing.static DefaultIndexOperationprepare(DocumentStore documentStore, Object object, @NonNull Object collection, String idPath, String beginPath, String endPath) Prepares a newDefaultIndexOperationinstance to manage document indexing with specified path mappings.static DefaultIndexOperationprepare(DocumentStore documentStore, Object object, @NonNull Object collection, Function<Object, ?> idFunction, Function<Object, Instant> beginFunction, Function<Object, Instant> endFunction) Prepares a newDefaultIndexOperationinstance for managing document indexing with specified functions for extracting key properties from the object.static DefaultIndexOperationprepareDelete(DocumentStore documentStore, @NonNull Object collection, @NonNull Object id) Prepares a newDefaultIndexOperationinstance for deleting a document from the specified collection in theDocumentStore.Converts the current state of the IndexOperation into aBulkUpdateinstance.Converts the current state of the IndexOperation into a Document instance.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface IndexOperation
addMetadata, addMetadata, addMetadata, collection, collection, end, end, id, id, ifNotExists, ifNotExists, index, indexAndForget, indexAndWait, indexAndWait, metadata, metadata, period, start, start, timestamp, value, value
-
Constructor Details
-
DefaultIndexOperation
public DefaultIndexOperation()
-
-
Method Details
-
prepare
public static DefaultIndexOperation prepare(DocumentStore documentStore, @NonNull @NonNull Object object) Prepare a newDefaultIndexOperationinstance for managing document indexing.- Parameters:
documentStore- theDocumentStoreused to store and manage the index operationsobject- 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 newDefaultIndexOperationinstance to manage document indexing with specified path mappings.- Parameters:
documentStore- theDocumentStoreused to store and manage the index operationsobject- the object to be indexed, which will be analyzed and converted for storagecollection- the collection in which the object residesidPath- the path used to determine the unique ID of the document; if null or blank, a new ID is generatedbeginPath- the path specifying the beginning timestamp of the document; ignored if nullendPath- the path specifying the ending timestamp of the document; defaults to corresponding begin timestamp if null- Returns:
- an initialized
DefaultIndexOperationfor 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 newDefaultIndexOperationinstance for managing document indexing with specified functions for extracting key properties from the object.- Parameters:
documentStore- theDocumentStoreused to manage and store index operationsobject- the object to be indexed, which will be analyzed and converted for storagecollection- the collection in which the object residesidFunction- aFunctionto extract the unique ID of the document from the objectbeginFunction- aFunctionto determine the beginning timestamp of the document from the objectendFunction- aFunctionto determine the ending timestamp of the document from the object- Returns:
- a fully initialized
DefaultIndexOperationfor 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 newDefaultIndexOperationinstance for deleting a document from the specified collection in theDocumentStore.- Parameters:
documentStore- theDocumentStoreused to store and manage the index operationscollection- the collection from which the document should be deletedid- the unique identifier of the document to be deleted- Returns:
- a
DefaultIndexOperationinstance configured for the delete operation
-
index
Description copied from interface:IndexOperationExecutes the indexing operation with the provided guarantee. If the value isnull, the document will be deleted.- Specified by:
indexin interfaceIndexOperation
-
toDocument
Description copied from interface:IndexOperationConverts the current state of the IndexOperation into a Document instance.- Specified by:
toDocumentin interfaceIndexOperation
-
toBulkUpdate
Description copied from interface:IndexOperationConverts the current state of the IndexOperation into aBulkUpdateinstance.- Specified by:
toBulkUpdatein interfaceIndexOperation
-
copy
Description copied from interface:IndexOperationCreates a deep copy of this operation, preserving all configured values.- Specified by:
copyin interfaceIndexOperation
-