【发布时间】:2020-11-24 10:13:25
【问题描述】:
我在弹性搜索中为对象创建了错误的映射。有没有办法更新映射。为对象类型(字符串而不是双精度)创建了错误的映射。
【问题讨论】:
标签: elasticsearch
我在弹性搜索中为对象创建了错误的映射。有没有办法更新映射。为对象类型(字符串而不是双精度)创建了错误的映射。
【问题讨论】:
标签: elasticsearch
一般来说,现有字段的映射无法更新。这条规则有一些例外。例如:
new properties can be added to Object datatype fields.
new multi-fields can be added to existing fields.
doc_values can be disabled, but not enabled.
the ignore_above parameter can be updated.
来源:https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html
【讨论】:
这完全有可能,通过PUTting 新映射覆盖现有的here are some examples。
请注意,完成此操作后,您可能需要重新索引所有数据,因为我认为 ES 不能将字符串索引转换为双索引。 (取而代之的是,当您在该字段中搜索时,您将找不到任何文档)
【讨论】:
PUT Mapping API 允许您在现有索引中添加/修改数据类型。
PUT /assets/asset/_mapping
{
"properties": {
"common_attributes.asset_id": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"doc_values": true,
"normalizer": "lowercase_normalizer"
}
}
},
}
}
更新映射后,使用批量更新 API 更新现有文档。
POST /_bulk
{"update":{"_id":"59519","_type":"asset","_index":"assets"}}
{"doc":{"facility_id":491},"detect_noop":false}
注意 - 使用 'detect_noop' 来检测 noop 更新。
【讨论】: