简体   繁体   中英

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. 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

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]')

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM