All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.kbods.elasticsearch.BulkIndexException.kt Maven / Gradle / Ivy

package org.kbods.elasticsearch

import co.elastic.clients.elasticsearch.core.BulkResponse


class BulkIndexException(val docErrors: Collection) : RuntimeException("Elasticsearch bulk index error") {

    constructor(bulkResponse: BulkResponse) : this(errors(bulkResponse))

    data class IndexErrorDocRef(
        val index: String,
        val id: String,
        val reason: String
    )

    companion object {
        private fun errors(bulkResponse: BulkResponse): Collection {
            return bulkResponse.items()
                .filter { it.error() != null }
                .map { item ->
                    IndexErrorDocRef(item.index(), item.id()!!, item.error()!!.reason()!!)
                }
                .toList()
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy