jillesvangurp / kt-search

Multi platform kotlin client for Elasticsearch & Opensearch with easily extendable Kotlin DSLs for queries, mappings, bulk, and more.
MIT License
95 stars 23 forks source link

[FEAT] update by query #72

Open AlexRychkov opened 1 year ago

AlexRychkov commented 1 year ago

Hello, in the first version of the lib it was possible to run an update by query with a script, but can't find similar functionality in current version

fun <T : Any> IndexRepository<T>.updateByQuery(
    esClient: RestHighLevelClient,
    script: Script,
    query: QueryBuilder,
) {
    val index = this.indexName
    val updateByQueryRequest = UpdateByQueryRequest(index)
    updateByQueryRequest.script = script
    updateByQueryRequest.setQuery(query)
    esClient.updateByQuery(
        updateByQueryRequest,
        RequestOptions.DEFAULT,
    )
}
jillesvangurp commented 1 year ago

Interesting. I've never used this myself. Shouldn't be too hard to add if you want to do a pull request for this.