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 TypeMethodDescriptiondefault IndexOperationaddMetadata(@NonNull Metadata metadata) Adds metadata to the index operation, merging with any previously set metadata.default IndexOperationaddMetadata(@NonNull Object key, Object value) Adds a single metadata key-value pair.default IndexOperationaddMetadata(@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.copy()Creates a deep copy of this operation, preserving all configured values.end()Returns the configured end timestamp for this operation.Sets the end time for the document (e.g., used in range queries or versioning).id()Returns the configured ID of the document.Sets the ID of the document to index.booleanWhether the operation is configured to only index if the document doesn't already exist.ifNotExists(boolean toggle) If set totrue, only index the document if it does not already exist.default CompletableFuture<Void> index()Executes the indexing operation with a default guarantee ofGuarantee.STORED.Executes the indexing operation with the provided guarantee.default voidExecutes the indexing operation with aGuarantee.NONEguarantee and does not wait for completion.default voidExecutes the indexing operation withGuarantee.STOREDand blocks until it is completed.default voidindexAndWait(Guarantee guarantee) Executes the indexing operation with the specified guarantee and blocks until it is completed.metadata()Returns the configured metadata.Replaces all metadata in this operation with the given metadata.default IndexOperationSets the start and end time using a time range.start()Returns the configured start timestamp for this operation.Sets the start time (timestamp) for the document.default IndexOperationSets both start and end time to the same instant (convenience method).Converts the current state of the IndexOperation into aBulkUpdateinstance.Converts the current state of the IndexOperation into a Document instance.value()Returns the configured value to be indexed.Sets the value to be indexed.
-
Method Details
-
index
Executes the indexing operation with a default guarantee ofGuarantee.STORED. -
indexAndForget
default void indexAndForget()Executes the indexing operation with aGuarantee.NONEguarantee and does not wait for completion. -
indexAndWait
default void indexAndWait()Executes the indexing operation withGuarantee.STOREDand blocks until it is completed. -
indexAndWait
Executes the indexing operation with the specified guarantee and blocks until it is completed. -
index
Executes the indexing operation with the provided guarantee. If the value isnull, the document will be deleted. -
id
Sets the ID of the document to index. -
collection
Sets the collection into which the document should be indexed. -
value
Sets the value to be indexed. If the value isnull, the document will be deleted whenindex()is invoked. -
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
Sets both start and end time to the same instant (convenience method). -
period
Sets the start and end time using a time range. -
addMetadata
Adds metadata to the index operation, merging with any previously set metadata. -
addMetadata
Adds a single metadata key-value pair. -
addMetadata
Adds multiple metadata entries from a map. -
metadata
Replaces all metadata in this operation with the given metadata. -
ifNotExists
If set totrue, 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
-
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. -
toDocument
SerializedDocument toDocument()Converts the current state of the IndexOperation into a Document instance. -
toBulkUpdate
BulkUpdate toBulkUpdate()Converts the current state of the IndexOperation into aBulkUpdateinstance. -
copy
IndexOperation copy()Creates a deep copy of this operation, preserving all configured values.
-