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 Summary
Modifier and TypeMethodDescriptiondefault IndexOperation
addMetadata
(@NonNull Metadata metadata) Adds metadata to the index operation, merging with any previously set metadata.default IndexOperation
addMetadata
(@NonNull Object key, Object value) Adds a single metadata key-value pair.default IndexOperation
addMetadata
(@NonNull Map<String, ?> values) Adds multiple metadata entries from a map.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.boolean
Whether 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 void
Executes the indexing operation with aGuarantee.NONE
guarantee and does not wait for completion.default void
Executes the indexing operation withGuarantee.STORED
and blocks until it is completed.default void
indexAndWait
(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 IndexOperation
Sets 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 IndexOperation
Sets both start and end time to the same instant (convenience method).
-
Method Details
-
index
Executes the indexing operation with a default guarantee ofGuarantee.STORED
. -
indexAndForget
default void indexAndForget()Executes the indexing operation with aGuarantee.NONE
guarantee and does not wait for completion. -
indexAndWait
default void indexAndWait()Executes the indexing operation withGuarantee.STORED
and 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. -
id
Sets the ID of the document to index. -
collection
Sets the collection into which the document should be indexed. -
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. -
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
IndexOperation copy()Creates a deep copy of this operation, preserving all configured values.
-