Skip to content

Instantly share code, notes, and snippets.

@erdii
Last active July 17, 2025 06:47
Show Gist options
  • Save erdii/359263c2f24e08b0eda1f6ef04b2f421 to your computer and use it in GitHub Desktop.
Save erdii/359263c2f24e08b0eda1f6ef04b2f421 to your computer and use it in GitHub Desktop.
Copy an elasticsearch index definition (settings and mapping - no data) to another server
# copy index definition
INDEX_NAME="my_index"
curl -X GET "http://source-server:9200/$INDEX_NAME" | curl -X PUT "http://destination-server:9200/$INDEX_NAME" -d @-
# copy mapping for "my_doc_type"
DOC_TYPE="my_doc_type"
curl -X GET "http://source-server:9200/$INDEX_NAME/_mapping" | jq .$INDEX_NAME.mappings.$DOC_TYPE | curl -X PUT "http://destination-server:9200/$INDEX_NAME/_mapping/$DOC_TYPE" -d @-
@saadismail
Copy link

Thanks @ferzerkerx, worked perfectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment