Skip to content

Commit

Permalink
Move the scroll ID from the DELETE /_search/scroll URL to its body.
Browse files Browse the repository at this point in the history
Scroll IDs can be too long for an HTTP request header, and so should
only be put in the body. Putting them in the URL was deprecated in
ElasticSearch 7.0.0 (April 2019).

The SearchClient.scroll method already does this, it was only
SearchClient.deleteScroll that did not.

See https://www.elastic.co/guide/en/elasticsearch/reference/current/clear-scroll-api.html
  • Loading branch information
ewanmellor committed Dec 23, 2024
1 parent 3916118 commit d7db4a0
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,14 @@ suspend fun SearchClient.scroll(scrollId: String, scroll: Duration = 60.seconds)
suspend fun SearchClient.deleteScroll(scrollId: String?): JsonObject {
return if (scrollId != null) {
restClient.delete {
path("_search", "scroll", scrollId)
path("_search", "scroll")
rawBody(
"""
{
"scroll_id": "$scrollId"
}
""".trimIndent()
)
}.parseJsonObject()
} else {
JsonObject(emptyMap())
Expand Down

0 comments on commit d7db4a0

Please sign in to comment.