jillesvangurp / kt-search

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

Add support for routing key per item in bulk #122

Closed csh97 closed 6 months ago

csh97 commented 6 months ago

Implements https://github.com/jillesvangurp/kt-search/issues/118

Adds support for specifying a routing key per item in a bulk request.

For example:

client.bulk(routing = "1") {
  index(source = objectMapper.writeValueAsString(doc1), index = indexName, id = doc1.id)
  index(source = objectMapper.writeValueAsString(doc2), index = indexName, id = doc2.id, routing = "2")
}

In the case where a routing key is passed as a bulk parameter for the whole request and at the individual item level, then the individual item will take precedence.