更新 ElasticSearch 映射

Updating ElasticSearch mapping

我有一个包含超过 30.000.000 个文档的索引。 我需要为即将到来的新文档添加一个新字段。 但是我需要指定这个新字段的正确映射。

此命令是否会导致对现有文档进行重新索引操作?

PUT /my_index/_mappings/my_type
{
   "my_type": {
      "properties": {
         "A": {
            "properties": {
               "new_field": {
                  "type": "string",
                  "analyzer": "analyzer_keyword"
               }
            }
         }
      }
   }
}

不,上面的查询不会导致任何类型的 re-indexing。这只会在您的 mapping.New 中添加一个新字段,如果您 update existing documentcreate new document。 您可以参考here了解更多详情。