[英]How to update/change the existing field type in a mapping of an index in elasticsearch using python?
I am trying to update a field type in my existing index mappings but getting BadRequestError using put_mapping method.我正在尝试更新现有索引映射中的字段类型,但使用 put_mapping 方法获取 BadRequestError。 The same method works to add a new field but not to update an existing one.
相同的方法适用于添加新字段,但不能更新现有字段。 Is there any other method available for the same?
是否有任何其他方法可用于相同的?
In the below example, i am trying to change the date format of start_time在下面的示例中,我正在尝试更改 start_time 的日期格式
es_client.indices.put_mapping(index='test-index',properties=properties)
This is the error i got这是我得到的错误
raise HTTP_EXCEPTIONS.get(meta.status, ApiError)(
elasticsearch.BadRequestError: BadRequestError(400, 'illegal_argument_exception', 'Mapper for [start_time] conflicts with existing mapper:\n\tCannot update parameter [format] from [yyyy-MM-dd HH:mm:ss||epoch_millis] to [yyyy-MM-dd HH:mm:ss]') elasticsearch.BadRequestError: BadRequestError(400, 'illegal_argument_exception', '[start_time] 的映射器与现有映射器冲突:\n\t无法将参数 [格式] 从 [yyyy-MM-dd HH:mm:ss||epoch_millis] 更新为 [ yyyy-MM-dd HH:mm:ss]')
It is not possible to change the mapping after creation of index if you want to change the mapping you would need to use Re-indexing API, for more information check the answer here: Elastic search, no mappings with filters如果要更改需要使用重新索引 API 的映射,则在创建索引后无法更改映射,有关更多信息,请查看此处的答案: 弹性搜索,无过滤器映射
as it has been mentioned above in the comments, you cannot change a mapping once the index has been created正如上面在评论中提到的那样,一旦创建索引,您就无法更改映射
you need to delete the index, then recreate it with the correct setting您需要删除索引,然后使用正确的设置重新创建它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.