How to update elastic search _source settings?

When I try to update the _source parameter in elastic search,I got an error. Can I change this settings?

PUT  source-test
POST source-test/_mappings
{
  "_source" : {
      "enabled":true
  }
}
POST source-test/_mappings
{
  "_source" : {
      "enabled":false
  }
}

{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "Mapper for [_source] conflicts with existing mapper:\n\tCannot update parameter [enabled] from [true] to [false]"
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "Mapper for [_source] conflicts with existing mapper:\n\tCannot update parameter [enabled] from [true] to [false]"
  },
  "status" : 400
}

You need to set that enabled field when creating an index. You cannot change that setting at runtime.

See _source field | Elasticsearch Guide [7.13] | Elastic

2 Likes