简体   繁体   English

如何使用 python 更新/更改 elasticsearch 中索引映射中的现有字段类型?

[英]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.

相关问题 如何使用Elasticsearch Mapping API更改现有索引的字段类型 - How to change field types for existing index using Elasticsearch Mapping API 更新Elasticsearch中已有字段的映射索引参数 - Update mapping index parameter of existing field in Elasticsearch 更新 Elasticsearch 中现有索引的映射 - Update Mapping of existing Index in Elasticsearch 是否可以通过Elasticsearch中的映射来更新索引中的现有字段? - Is it possible to update an existing field in an index through mapping in Elasticsearch? ElasticSearch:如何更新现有索引中的文档类型 - ElasticSearch: How to update a document type in an existing index 如何使用php更改ElasticSearch中的现有映射? - How to change existing mapping in ElasticSearch using php? 如何更新Elasticsearch中的映射以更改字段数据类型并更改字符串中的分析器类型 - How to update the mapping in Elasticsearch to change the field datatype and change the type of analyzers in string 如何更改 ElasticSearch 索引中的字段类型? - How to change the field type in an ElasticSearch Index? 在elasticsearch中为具有新类型的现有索引创建映射 - Creating a mapping for an existing index with a new type in elasticsearch 是否可以更新 ElasticSearch 6.x 索引中现有字段映射的“存储”值? - Is it possible to update `store` value of the mapping of an existing field in ElasticSearch 6.x index?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM