You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
package main
import (
"bytes"
"dsTools/Utils/EsUtil"
"dsTools/Utils/FileUtil"
"encoding/json"
"fmt"
jsoniter "github.com/json-iterator/go"
)
func main ( ) {
//1、http请求, 获取有哪些索引
var indexNameArr = EsUtil . GetAllIndex ( )
//2、遍历所有的索引
for i := 0 ; i < len ( indexNameArr ) ; i ++ {
index := indexNameArr [ i ]
mappingStr , err := EsUtil . GetMapping ( index )
//转为json+去掉表名
mappingStr = jsoniter . Get ( [ ] byte ( mappingStr ) , index ) . ToString ( )
if err == nil {
mappingStr = ` { "settings": { "number_of_shards":5,"index.refresh_interval":"5s"}, ` + mappingStr [ 1 : len ( mappingStr ) - 1 ] + "}"
var str bytes . Buffer
_ = json . Indent ( & str , [ ] byte ( mappingStr ) , "" , " " )
//形成文件
FileUtil . WriteToFile ( "./MappingBackupJson/" + index + ".json" , str . String ( ) )
}
}
fmt . Println ( "恭喜,所有操作成功完成!" )
}