脚本批量导入导出es表结构

批量导出

#使用脚本导出ElasticSearch所有mapping
for index in $(curl -u elastic:elastic -XGET 'http://192.168.100.110:9200/_cat/indices?v' | awk '{print $3}' | grep -vE '\.(kibana|tasks|operations)\b'); do
  curl  -u elastic:elastic -XGET "http://192.168.100.110:9200/$index/_mapping" > "$index.json"
done

批量导入(需要elasticdump)

默认会创建五个分片,一个副本

#!/bin/sh
for index in $(ls /home/esdump/data/es_mapping |grep .json); do
  without=$(echo $index | sed 's/\.json//')
#  echo $without
#  echo $index
  /home/esdump/node_modules/elasticdump/bin/elasticdump --input="/home/esdump/data/es_mapping/$index" --output=http://192.168.100.90:9200/${without}  --type=mapping
done

你可能感兴趣的:(elasticsearch)