I can't delete derived field

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser): 3.3.0

Describe the issue:

I created the derived field with the following command:

PUT iislog/_mapping
{
“derived”: {
“file”: {
“type”: “keyword”,
“script”: “”"
def str=/./(.)/.matcher(doc[‘url.keyword’].value);
if (str.find()) {
emit(str.group(1))
}
“”"
}
}
}

However, it cannot be deleted with the following command:

PUT iislog/_mapping
{
“derived”: {
“file”: null
}
}

{
“error”: {
“root_cause”: [
{
“type”: “mapper_parsing_exception”,
“reason”: “Expected map for property [derived_fields] on field [file] but got a class java.lang.String”
}
],
“type”: “mapper_parsing_exception”,
“reason”: “Expected map for property [derived_fields] on field [file] but got a class java.lang.String”
},
“status”: 400
}

Can’t derived field be deleted?

Configuration:

Relevant Logs or Screenshots:

@mhkang589 I think the derived fields cannot be deleted, this follows the general rule of updating mappings in OpenSearch, You can add a field to mappings, but not delete it.

There are a number of workaround however:

  1. If this is the only derived field, you can disabled the derived fields on that index, using the following:
PUT iislog/_settings
{
  "index.query.derived_field.enabled": false
}
  1. You can skip the emit stage by updating the derived field as follows:
"source": """
        // Intentionally emit nothing: derived field will always be empty
          if (false) {
            emit("");
          }
        """
  1. If you absolutely need to remove this field reindexing is the last option.

Thank you for your reply.

But it doesn’t get deleted with the following command.

PUT iislog/_settings
{
“index.query.derived_field.enabled”: false
}

PUT iislog/_mapping
{
“derived”: {
“test1”: {
“type”: “keyword”,
“script”: {
“source”: “”"
if (false) {
emit(“”);
}
“”"
}
}
}
}

When creating, it is only created as an unknown type.
I don’t think this is normal behavior. :joy: