jillesvangurp / kt-search

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

Add support for routing key per item in bulk #122

Closed csh97 closed 8 months ago

csh97 commented 8 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.