Skip to content

[BUG] Constant keyword field type not working - index created in a defect state #14638

@securitym0nkey

Description

@securitym0nkey

Describe the bug

When trying to create an index with a constant_keyword field the index is created but fails to initialize the shards. Leaving the index in a defect state.

The logs show an error like the following, giving the hint that the mandatory value attribute is missing, though it was specified when creating the index.

[2024-07-03T16:26:47,523][WARN ][o.o.c.r.a.AllocationService] [opensearch-nodes-0] failing shard [failed shard, shard [romcom_movies][0], node[ZT3MePnSSUCwmjmHl2GVPA], [P], recovery_source[new shard recovery], s[INITIALIZING], a[id=5Xd3-2t9TZSOd-04YVLWug], unassigned_info[[reason=ALLOCATION_FAILED], at[2024-07-03T16:26:47.412Z], failed_attempts[4], failed_nodes[[ZT3MePnSSUCwmjmHl2GVPA, regeJ4etSYqEWfZNO-Z4CA]], delayed=false, details[failed shard on node [regeJ4etSYqEWfZNO-Z4CA]: failed to update mapping for index, failure MapperParsingException[Failed to parse mapping [_doc]: Field [genre] is missing required parameter [value]]; nested: OpenSearchParseException[Field [genre] is missing required parameter [value]]; ], allocation_status[no_attempt]], message [failed to update mapping for index], failure [MapperParsingException[Failed to parse mapping [_doc]: Field [genre] is missing required parameter [value]]; nested: OpenSearchParseException[Field [genre] is missing required parameter [value]]; ], markAsStale [true]]

Related component

Indexing

To Reproduce

Just run the snippet from the documentation.

PUT romcom_movies
{
  "mappings" : {
    "properties" : {
      "genre" : {
        "type": "constant_keyword",
        "value" : "Romantic comedy"
      }
    }
  }
}

The request will take a long time and finally fail with a 400 error, but the index is created.

Note when running GET romcom_movies the value attribute is actually missing.

{
  "romcom_movies": {
    "aliases": {},
    "mappings": {
      "properties": {
        "genre": {
          "type": "constant_keyword"
        }
      }
    },
    "settings": {
      "index": {
        "replication": {
          "type": "DOCUMENT"
        },
        "number_of_shards": "1",
        "provided_name": "romcom_movies",
        "creation_date": "1720024006906",
        "number_of_replicas": "1",
        "uuid": "cHW2U7hQR3iZ8mtRQOo4_w",
        "version": {
          "created": "136367827"
        }
      }
    }
  }
}

Expected behavior

Index gets created and works like described in the documentation.

Additional Details

Plugins
default plugins

Host/Environment (please complete the following information):

  • OS: container on k8s
  • Version 2.15.0

Metadata

Metadata

Assignees

Labels

IndexingIndexing, Bulk Indexing and anything related to indexingbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions