-
-
Save erdii/359263c2f24e08b0eda1f6ef04b2f421 to your computer and use it in GitHub Desktop.
# 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 @- |
I am trying to copy the index definition from one index to another index within the same server. I have used copy_elasticsearch_index_to_other_server.sh script and getting below error. please suggest what changes are required here.
{"error":"Content-Type header [application/x-www-form-urlencoded] is not supported","status":406}
Modified script and added header as content-type header as application-json, but this time different error I am getting
{"error":{"root_cause":[{"type":"parse_exception","reason":"unknown key [indexname] for create index"}],"type":"parse_exception
Modified script and added header as content-type header as application-json, but this time different error I am getting
{"error":{"root_cause":[{"type":"parse_exception","reason":"unknown key [indexname] for create index"}],"type":"parse_exception
The response from the index details (curl -X GET "http://source-server:9200/$INDEX_NAME") contains the index as a key which is what the error is saying. In this case the resulting JSON needs to be modified to be able to send it as a request
curl -sX GET "http://source-server:9200/$INDEX_NAME" | jq "to_entries[0].value" | jq "del(.settings.index.creation_date, .settings.index.uuid, .settings.index.provided_name, .settings.index.version.created)" | curl -sX PUT "http://destination-server:9200/$INDEX_NAME" -H 'Content-Type: application/json' -d @-
Thanks