Package 

Class AsyncBulkIndexingSession


  • 
    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.

    • 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 the updateFunction 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 the updateFunction in case of a version conflict.