一个用于ElasticSearch运维的命令行工具集。
pip install eshelpergit clone https://github.com/Haoke98/ElasticSearchHelper.git
cd ElasticSearchHelper
pip install -e .在使用之前,需要配置ElasticSearch连接信息。你可以通过以下两种方式之一配置环境变量:
- 在环境变量文件(.env)中配置:
SLRC_ES_PROTOCOL=https
SLRC_ES_HOST=your-es-host:9200
SLRC_ES_USERNAME=your-username
SLRC_ES_PASSWORD=your-password
SLRC_ES_CA=/path/to/ca.crt # 如果使用https- 使用
-e选项指定环境变量文件:
es-helper -e /path/to/your.env <command>注意:如果不指定环境变量文件,程序会自动寻找当前目录下的
.env文件。
安装后可以使用es-helper命令,支持以下功能:
-e, --env-file: 指定环境变量文件路径,可用于所有子命令
es-helper task --id "task-id"输出示例:
状态:正在运行.....
已运行:0:58:30.512872
进度:23.07%
速率:73.16/秒
预估完成于:2024-12-09 22:38:21
从CSV文件生成ES索引mapping:
es-helper generate-map -i fields.csv --obj2nested支持的选项:
-i, --input: 输入CSV文件路径(必需)-o, --output: 输出JSON文件路径(可选)--obj2nested: 将object类型转换为nested类型-f, --full: 生成完整模式的mapping
从ES索引导出字段列表:
es-helper export-field-table -i index-name -gsm选项说明:
-i, --index: ES索引名称-d, --export_dir: 导出目录-gsm, --guess-meaning: 使用LLM推测字段含义
根据映射关系重建索引:
es-helper reindex -s source-index -d dest-index -m mapping.csv参数说明:
-s, --source: 源索引名称-d, --destination: 目标索引名称-m, --mapping: 字段映射文件(CSV格式)-b, --batch-size: 批处理大小(默认1000)--strict: 严格模式,只映射在映射表中定义的字段
Apache License 2.0