Skip to content

Put template APIs should only wrap a top level _doc json object field to the mapping if it is missing #71761

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

Closed
martijnvg opened this issue Apr 15, 2021 · 3 comments
Labels
>bug :Data Management/Indices APIs APIs to create and manage indices and templates Team:Data Management Meta label for data/management team

Comments

@martijnvg
Copy link
Member

Component and composable templates should accept mappings with and without a top level _doc json object.
If the top level _doc json field is missing then it should be added to the mapping and if it already exists then
the mapping doesn't need to be modified.

Currently in 8.0-snapshot (master) the put component and composable index templates add a toplevel _doc json
object to the mapping if it missing. However in 7.x and before this is not the case and if a mapping with _doc json
object as top level field is added then an error is returned that the root mapping as unsupported parameters. This
is because a mapping in a template is always wrapped in toplevel _doc json object field.

Composable index template case:

PUT _index_template/my-template
{
    "index_patterns": [
        "my-logs-*"
    ],
    "template": {
        "mappings": {
            "_doc": {
                "properties": {
                    "@timestamp": {
                        "type": "date"
                    }
                }
            }
        }
    }
}

The above request fails with a mapper exception (Root mapping definition has unsupported parameters: [_doc : {properties={@timestamp={type=date}}}]").

{
    "index_patterns": [
        "my-logs-*"
    ],
    "template": {
        "mappings": {
            "properties": {
                "@timestamp": {
                    "type": "date"
                }
            }
        }
    }
}

The above request succeeds.

Component template case:

PUT /_component_template/my-template
{
    "template": {
        "mappings": {
            "_doc": {
                "properties": {
                    "@timestamp": {
                        "type": "date"
                    }
                }
            }
        }
    }
}

The above request also fails with a mapper exception (Root mapping definition has unsupported parameters: [_doc : {properties={@timestamp={type=date}}}]").

PUT /_component_template/my-template
{
    "template": {
        "mappings": {
            "properties": {
                "@timestamp": {
                    "type": "date"
                }
            }
        }
    }
}

The above request succeeds.

@martijnvg martijnvg added >bug :Data Management/Indices APIs APIs to create and manage indices and templates labels Apr 15, 2021
@elasticmachine elasticmachine added the Team:Data Management Meta label for data/management team label Apr 15, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-features (Team:Core/Features)

@martijnvg
Copy link
Member Author

The master branch contains #58867, however this change was never back ported to the 7.x branch.

@martijnvg
Copy link
Member Author

Fixed via #58969 in 7.x branch. The fix will be included in the 7.14 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Data Management/Indices APIs APIs to create and manage indices and templates Team:Data Management Meta label for data/management team
Projects
None yet
Development

No branches or pull requests

2 participants