关闭ElasticSearch动态创建mapping

使用ElasticSearch的默认配置会使我们在索引不存在于mapping中的字段时,会自动创建
我们可以设置关闭动态创建mapping
 
执行如下操作:
PUT /索引名/索引类型/_mapping
{
  "dynamic":false
}
更严格一点可以设置不在mapping中的字段的数据不能写入ES

{
  "dynamic":"strict"
}

这样我们之后写入非手动创建的其他字段数据时会得到如下错误:

mapping set to strict, dynamic introduction of [hatae] within [data] is not allowed



  世间万物
      花是花,草是草,你是你,我是我
          只要拥有这样的自由,满心才是欢喜



原文地址:https://www.cnblogs.com/merely/p/12597987.html