-
public final class AsyncBulkIndexingSession<T extends Object>
Asynchronous bulk indexing that uses the experimental Kotlin flows. Works similar to the synchronous version except it fires bulk requests asynchronously. On paper using multiple threads, allows ES to use multiple Threads to consume bulk requests.
Note: you need the kotlin.Experimental flag set for this to work. As Flow is a bit in flux, I expect the internals of this may change still before they finalize this. So, beware when using this.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public class
AsyncBulkIndexingSession.Companion
-
Constructor Summary
Constructors Constructor Description AsyncBulkIndexingSession(AsyncIndexRepository<T> repository, ModelReaderAndWriter<T> modelReaderAndWriter, Integer retryConflictingUpdates, SendChannel<AsyncBulkOperation<T>> operationChannel, SuspendFunction2<AsyncBulkOperation<T>, BulkItemResponse, Unit> itemCallback, RequestOptions defaultRequestOptions)
-
Method Summary
Modifier and Type Method Description final Unit
index(String id, T obj, Boolean create)
final Unit
getAndUpdate(String id, SuspendFunction1<T, T> updateFunction)
Safe way to bulk update objects. final Unit
update(String id, Long seqNo, Long primaryTerms, T original, SuspendFunction1<T, T> updateFunction)
Bulk update objects. final Unit
delete(String id, Long seqNo, Long term)
Delete an object from the index. -
-
Constructor Detail
-
AsyncBulkIndexingSession
AsyncBulkIndexingSession(AsyncIndexRepository<T> repository, ModelReaderAndWriter<T> modelReaderAndWriter, Integer retryConflictingUpdates, SendChannel<AsyncBulkOperation<T>> operationChannel, SuspendFunction2<AsyncBulkOperation<T>, BulkItemResponse, Unit> itemCallback, RequestOptions defaultRequestOptions)
-
-
Method Detail
-
getAndUpdate
final Unit getAndUpdate(String id, SuspendFunction1<T, T> updateFunction)
Safe way to bulk update objects. Gets the object from the index first before applying the lambda to it to modify the existing object. If you set
retryConflictingUpdates
0, it will attempt to retry to get the latest document and apply theupdateFunction
if there is a version conflict.
-
update
final Unit update(String id, Long seqNo, Long primaryTerms, T original, SuspendFunction1<T, T> updateFunction)
Bulk update objects. If you have the object (e.g. because you are processing the sequence of a scrolling search), you can update what you have in a safe way. If you set
retryConflictingUpdates
0, it will retry by getting the latest version and re-applying theupdateFunction
in case of a version conflict.
-
-
-
-