如何手动创建CSV的Elasticsearch映射及索引模板?解决索引冲突
为CSV数据创建Elasticsearch索引模板的实操步骤
1. 清理已存在的冲突索引
因为你已创建movie1索引,先删除它避免后续操作冲突:
DELETE /movie1
2. 创建自定义索引模板
索引模板会在你创建新索引时自动应用预设映射规则,无需依赖Kibana的自动生成工具。执行以下命令创建模板(模板默认匹配所有以movie开头的索引,也可将index_patterns改为精确的movie1):
PUT _index_template/movie_template { "index_patterns": ["movie*"], "template": { "mappings": { "properties": { "Actor Name": { "type": "text" }, "Category": { "type": "text" }, "Cinema Involved": { "type": "text" }, "Expense of Operation": { "type": "text" }, "Movie Description": { "type": "text" }, "Movie ID": { "type": "text" }, "Movie Length": { "type": "text" }, "Movie Name": { "type": "text" }, "Movie Origin": { "type": "text" }, "Movie Release Date": { "type": "text" }, "Movie Type": { "type": "text" } } } }, "priority": 100 }
index_patterns:定义模板匹配的索引名称规则,movie*会覆盖所有以movie开头的索引priority:设置模板优先级(数值越高优先级越高),确保自定义模板能覆盖系统默认模板
3. 上传CSV并指定索引名
在Kibana中上传CSV时:
- 跳过file-data-visualizer的自动映射流程,直接选择手动指定索引
- 输入索引名
movie1,Elasticsearch会自动匹配你创建的movie_template模板,应用预设映射完成数据导入
内容的提问来源于stack exchange,提问作者attack
相关产品推荐
相关产品推荐

