Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
securitym0nkey opened this issue Jul 3, 2024 · 3 comments · Fixed by #14807
Closed
Assignees
Labels
bug Something isn't working Indexing Indexing, Bulk Indexing and anything related to indexing

Comments

@securitym0nkey
Copy link

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
@securitym0nkey securitym0nkey added bug Something isn't working untriaged labels Jul 3, 2024
@github-actions github-actions bot added the Indexing Indexing, Bulk Indexing and anything related to indexing label Jul 3, 2024
@kkewwei
Copy link
Contributor

kkewwei commented Jul 4, 2024

@securitym0nkey, yes, it's a bug, i will pleasure to fix it, if you haven't do.

@kkewwei
Copy link
Contributor

kkewwei commented Jul 4, 2024

@securitym0nkey I have found the reason, the reason is we set the default value for the type incorrectly, so the value is not serialized in the cluster metadata.

@dblock
Copy link
Member

dblock commented Jul 18, 2024

Looks like it was introduced in #12285, cc: @hasnain2808 @msfroh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Indexing Indexing, Bulk Indexing and anything related to indexing
Projects
None yet
4 participants