1、客户创建索引请求如下,mapping没有web_content字段:
PUT /index_bookmark_v2
{
"settings": {
"number_of_replicas": 0,
"number_of_shards": 15
},
"mappings": {
"properties" : {
"archive_name" : {
"type" : "keyword"
},
"archiving" : {
"type" : "long"
},
"article_name" : {
"type" : "keyword"
},
"article_score" : {
"type" : "float"
},
"article_site_type" : {
"type" : "long"
},
"article_status" : {
"type" : "long"
},
"content" : {
"type" : "text",
"analyzer" : "ik_max_word"
},
"cover" : {
"type" : "keyword"
},
"create_time" : {
"type" : "long"
},
"description" : {
"type" : "keyword",
"normalizer" : "lowercase"
},
"has_mark" : {
"type" : "long"
},
"id" : {
"type" : "keyword"
},
"is_read" : {
"type" : "long"
},
"sourceType" : {
"type" : "long"
},
"star_target" : {
"type" : "long"
},
"state" : {
"type" : "long"
},
"tags" : {
"type" : "keyword",
"normalizer" : "lowercase"
},
"title" : {
"type" : "keyword",
"normalizer" : "lowercase"
},
"type" : {
"type" : "long"
},
"update_time" : {
"type" : "long"
},
"url" : {
"type" : "keyword",
"normalizer" : "lowercase"
},
"user_id" : {
"type" : "keyword"
},
"wechat_msgtime" : {
"type" : "long"
}
}
}
}
2、通过reindex同步数据到新索引,出现报错
_reindex
API 将数据从old_index复制到new_index,并在过程中删除web_content字段。可以使用source
和dest
参数指定源索引和目标索引,然后使用script
参数删除字段1、创建一个新的索引,例如 new_index。你可以使用 Elasticsearch 的 PUT
API 创建新索引。确保新索引的映射不包含 web_content 字段。创建索引请求上文已提供。
2、使用_reindexAPI 将数据从old_inde复制到new_index,并在过程中删除web_content字段。可以使用source和dest参数指定源索引和目标索引,然后使用script参数删除字段
curl -X POST "localhost:9200/_reindex" -H 'Content-Type: application/json' -d'
{
"source": {
"index": "old_index"
},
"dest": {
"index": "new_index"
},
"script": {
"lang": "painless",
"source": "ctx._source.remove(\"web_content \")"
}
}'
3、会议引导用户操作后数据成功同步到新索引,web_content 字段也删掉了
reindex参考文档:https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-reindex.html
Painless script参考文档:https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。