Skip to content

Commit

Permalink
Replace buildBulkHttpBody-method (#3105)
Browse files Browse the repository at this point in the history
  • Loading branch information
Philippus committed Jul 3, 2024
1 parent 3f02cb8 commit 96e4c13
Showing 1 changed file with 1 addition and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ trait BulkHandlers {
implicit object BulkHandler extends Handler[BulkRequest, BulkResponse] {

override def build(bulk: BulkRequest): ElasticRequest = {
val httpBody: String = buildBulkHttpBody(bulk)
val httpBody: String = BulkBuilderFn(bulk).mkString("", "\n", "\n")
val entity = HttpEntity(httpBody, "application/x-ndjson")
if (logger.isDebugEnabled()) {
logger.debug("Sending bulk request")
Expand All @@ -25,12 +25,4 @@ trait BulkHandlers {
ElasticRequest("POST", "/_bulk", params.toMap, entity)
}
}

private[bulk] def buildBulkHttpBody(bulk: BulkRequest): String = {
val builder = StringBuilder.newBuilder
val rows: Iterator[String] = BulkBuilderFn(bulk)
rows.addString(builder, "", "\n", "")
builder.append("\n") // es seems to require a trailing new line as well
builder.mkString
}
}

0 comments on commit 96e4c13

Please sign in to comment.