[英]Migrate elasticsearch mapping with curl
我想通過將映射的輸出管道化為curl來使用curl遷移索引的elasticsearch映射。
目的是為另一個主機上的索引遷移或創建映射。
現在,我運行以下命令:
curl -X GET "http://$SOURCE_HOSTNAME:9200/$SOURCE_INDEX/_mapping?pretty" | curl -X PUT "http://$DESTINATION_HOSTNAME:9200/$DESTINATION_INDEX/_mapping?pretty" -H 'Content-Type: application/json' -d "$(</dev/stdin)"
但是我收到以下錯誤。
{
"error" : {
"root_cause" : [
{
"type" : "action_request_validation_exception",
"reason" : "Validation Failed: 1: mapping type is missing;"
}
],
"type" : "action_request_validation_exception",
"reason" : "Validation Failed: 1: mapping type is missing;"
},
"status" : 400
}
此處聲稱正確的輸出缺少映射類型,這似乎很奇怪。
直接從json文件讀取時發生相同的問題
有兩個問題。 第一個是您從GET $SOURCE_INDEX/_mapping
調用中獲得的結果包含映射,但是它包裝在另一個名為源索引的屬性中。
例如, GET _mapping
調用將返回以下內容:
{
"your_index_name": { <--- your mapping is wrapped within the source index name
"mappings": { <--- and also within the mappings structure
"doc": { <--- this is the structure you need when hitting the _mapping endpoint
...
}
}
}
}
第二個問題是您的目標URL缺少映射類型名稱,即應為$DESTINATION_INDEX/_mapping/$SOME_TYPE
。
因此,您需要:
jq
來執行此操作
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.