我试图更改索引的映射,但收到错误.以下是我创建索引的步骤
通过python脚本填充索引来创建索引
使用以下代码设置映射:
PUT /myidx/orderrow/_mapping { "orderrow": { "properties": { "item_code": { "type": "string", "index": "not_analyzed" } } } }
这是我收到的错误消息:
{ "error": "MergeMappingException[Merge failed with failures {[mapper [item_code] has different index values, mapper [item_code] has different `norms.enabled` values, mapper [item_code] has different tokenize values, mapper [item_code] has different index_analyzer]}]", "status": 400 }
有任何想法吗?
由于您首先将数据索引到索引中,因此Elasticsearch会item_code
根据加载的数据自动检测字段的字段类型/映射.然后,当您尝试更新映射时,您将收到上面显示的错误.
我建议在运行Python脚本之前创建索引并应用映射来填充索引.
PUT /myproj/ PUT /myproj/orderrow/_mapping { "orderrow": { "properties": { "item_code": { "type": "string", "index": "not_analyzed" } } } }
或者,您可以使用Put Mapping API文档ignore_conflicts
的合并和冲突部分中定义的选项,将冲突映射强制转换为索引.但是,我不确定这将如何影响已编入索引的文档.