Skip to content

Mapping type changes not properly validated with subobjects: false #120216

Description

@flash1293

Elasticsearch Version

main

Installed Plugins

No response

Java Version

bundled

OS Version

MacOS 15.2

Problem Description

When using subobjects: false, the usual validation when changing field types is not triggered. Elasticsearch does change the type but will fail ingesting additional documents.

Steps to Reproduce

// step 1: create index
PUT my-index
{
  "mappings": {
    "subobjects": false,
    "properties": {
      "user.id": {
        "type": "long"
      }
    }
  }
}

// step 2: add some data
POST my-index/_doc
{
  "user.id": 123
}

// step 3: change mapping (succeeds by shouldn't)
PUT my-index/_mapping
{
    "properties": {
      "user.id": {
        "type": "keyword"
      }
    }
}

// step 4:trying to add more data fails
POST my-index/_doc
{
  "user.id": 123
}

This fails in step 4 with cannot change field "user.id" from index options=NONE to inconsistent index options=DOCS

Executing the same series of commands but omitting "subobjects": false in step 1 fails as expected in step 3 with mapper [user.id] cannot be changed from type [long] to [keyword] - this is what should happen with subobjects: false as well.

Logs (if relevant)

No response

Activity

  1. self-assigned this
    on Jan 16, 2025
  2. elasticsearchmachine commented on Jan 16, 2025

    @elasticsearchmachine
    Collaborator

    Pinging @elastic/es-storage-engine (Team:StorageEngine)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions