Hi.
I have an index which have stored fields in the documents. But, upon updating the document with new fields (partially update), the previously existing stored fields are getting deleted.
- Create the Index
PUT itf_test_index
{
"mappings": {
"_source": {
"excludes": [ "inference*", "metric*"]
},
"dynamic_templates": [
{
"inference_fields": {
"match": "inference*",
"mapping": {
"index": false,
"store": true,
"type": "text"
}
}
},
{
"metric_fields": {
"match": "metric*",
"mapping": {
"index": false,
"store": true,
"type": "text"
}
}
}
]
}
}
- Create a document
POST itf_test_index/_create/1
{
"imageName": "123.jpg",
"attribute_1": "Cat",
"inference_1": "inference_1"
}
- Result of _search at this point
GET itf_test_index/_search
{
"_source": ["*"],
"stored_fields": ["*"]
}
######
"hits": [
{
"_index": "itf_test_index",
"_id": "1",
"_score": 1,
"_source": {
"imageName": "123.jpg",
"attribute_1": "Cat"
},
"fields": {
"inference_1": [
"inference_1"
]
}
}
]
- Updating the document
POST itf_test_index/_update/1
{
"doc": {
"metric_1" : "metric_1"
}
}
- Result at this point
GET itf_test_index/_search
{
"_source": ["*"],
"stored_fields": ["*"]
}
#######
"hits": [
{
"_index": "itf_test_index",
"_id": "1",
"_score": 1,
"_source": {
"imageName": "123.jpg",
"attribute_1": "Cat"
},
"fields": {
"metric_1": [
"metric_1"
]
}
}
]
Here "inference_1" is not available any more. What exactly should I do at step 4 to preserve existing stored fields?
Thank you.