Skip to content

Instantly share code, notes, and snippets.

@HakanL
Created August 20, 2024 13:25
Show Gist options
  • Save HakanL/63f0874c8168ec372142a14c38f8a77d to your computer and use it in GitHub Desktop.
Save HakanL/63f0874c8168ec372142a14c38f8a77d to your computer and use it in GitHub Desktop.
Shrink an ElasticSearch Index
PUT /XXXXX/_settings
{
"settings": {
"index.blocks.write": true
}
}
POST /XXXXX/_split/XXXXX_split
{
"settings": {
"index.number_of_shards": 2,
"index.number_of_replicas": 0
}
}
POST /XXXXX_split/_shrink/XXXXX_shrunk
{
"settings": {
"index.number_of_shards": 1,
"index.number_of_replicas": 0,
"index.codec": "best_compression"
}
}
POST /XXXXX_shrunk/_forcemerge
DELETE /XXXXX
DELETE /XXXXX_split
POST /_reindex
{
"source": {
"index": "XXXXX_shrunk"
},
"dest": {
"index": "XXXXX"
}
}
PUT /XXXXX/_settings
{
"settings": {
"index.number_of_replicas": 0
}
}
DELETE /XXXXX_shrunk
PUT /XXXXX/_settings
{
"settings": {
"index.routing.allocation.require._name": null,
"index.blocks.write": null
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment