Skip to content

Instantly share code, notes, and snippets.

@benhowes
Last active October 26, 2020 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benhowes/990b8e1365a8e0dad6afa7b46593636a to your computer and use it in GitHub Desktop.
Save benhowes/990b8e1365a8e0dad6afa7b46593636a to your computer and use it in GitHub Desktop.
# Minimal reproduction of
# "the [include_in_root] parameter can't be updated on a nested object mapping"
# When that error would not be expected
#
# Seems to happen with `settings.index.number_of_shards` > 1
#
# Tested against Elasticsearch 7.9.2
ES_HOST=localhost:19200
curl -X PUT $ES_HOST/_template/template_1 -H 'Content-Type: application/json' -d'{
"index_patterns": ["test.*"],
"order": 0,
"version": 2,
"settings": {
"index": {
"priority": 5,
"number_of_shards": 3
}
},
"mappings": {
"dynamic_templates": [
{
"nested": {
"match": "*#nested",
"mapping": {
"type": "nested",
"include_in_parent": true,
"include_in_root": true
}
}
}
]
}
}'
curl -X PUT $ES_HOST/test.aaa
curl -X POST $ES_HOST/_bulk -H 'Content-Type: application/json' -d'
{ "index" : { "_index" : "test.aaa", "_id" : "1" } }
{"field#nested": [{"value": "aaa"}, {"value":"aaa_2"}]}
{ "index" : { "_index" : "test.aaa", "_id" : "2" } }
{"field#nested": [{"value": "bbb"}, {"value":"aaa_2"}]}
{ "index" : { "_index" : "test.aaa", "_id" : "3" } }
{"field#nested": [{"value": "ccc"}, {"value":"aaa_2"}]}
{ "index" : { "_index" : "test.aaa", "_id" : "4" } }
{"field#nested": [{"value": "ddd"}, {"value":"aaa_2"}]}
{ "index" : { "_index" : "test.aaa", "_id" : "5" } }
{"field#nested": [{"value": "ccc"}, {"value":"aaa_2"}]}
{ "index" : { "_index" : "test.aaa", "_id" : "6" } }
{"field#nested": [{"value": "ddd"}, {"value":"aaa_2"}]}
{ "index" : { "_index" : "test.aaa", "_id" : "7" } }
'
curl $ES_HOST/test.aaa/
curl -X DELETE $ES_HOST/test.aaa
curl -X DELETE $ES_HOST/_template/template_1
{
"took": 63,
"errors": true,
"items": [
{
"index": {
"_index": "test.aaa",
"_type": "_doc",
"_id": "1",
"status": 500,
"error": {
"type": "mapper_exception",
"reason": "the [include_in_root] parameter can't be updated on a nested object mapping"
}
}
},
{
"index": {
"_index": "test.aaa",
"_type": "_doc",
"_id": "2",
"_version": 1,
"result": "created",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"_seq_no": 0,
"_primary_term": 1,
"status": 201
}
},
{
"index": {
"_index": "test.aaa",
"_type": "_doc",
"_id": "3",
"_version": 1,
"result": "created",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"_seq_no": 1,
"_primary_term": 1,
"status": 201
}
},
{
"index": {
"_index": "test.aaa",
"_type": "_doc",
"_id": "4",
"_version": 1,
"result": "created",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"_seq_no": 2,
"_primary_term": 1,
"status": 201
}
},
{
"index": {
"_index": "test.aaa",
"_type": "_doc",
"_id": "5",
"status": 500,
"error": {
"type": "mapper_exception",
"reason": "the [include_in_root] parameter can't be updated on a nested object mapping"
}
}
},
{
"index": {
"_index": "test.aaa",
"_type": "_doc",
"_id": "6",
"_version": 1,
"result": "created",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"_seq_no": 0,
"_primary_term": 1,
"status": 201
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment