shell 脚本创建 es 索引

2,952 阅读1分钟

1.Es 配置文件 elasticsearch.yml 中 network.host: 0.0.0.0,重启 es

2.创建一个 create_index.sh 脚本

#!/bin/bash

#创建索引 road_crossing
curl -H "Content-Type: application/json" -u 账号:密码 -XPUT 'http://你的 es 主机 ip:es 端口/索引名' -d '{"settings":{ "analysis":{"analyzer":{ "standard_analyzer":{ "tokenizer":"standard" } "ik_analyzer":{ "tokenizer":"ik_max_word" }, "ik_search_analyzer":{ "tokenizer":"ik_smart" } } } }, "mappings":{ "properties":{ "guid":{ "type":"keyword" } } } }';

3.运行 sh create_index.sh ,如果返回类似以下的输出表示创建成功

{"acknowledged":true,"shards_acknowledged":true,"index":"索引名"}