Apparently, the simulate ingest API does not consider index mappings of docs._index it is simulating, so the mapper_parsing_exception does not occur here. But you see the stringified 'templates' objects I would like to have inserted as objects...
POST /_ingest/pipeline/_simulate
{
"pipeline" :
{
"processors": [
{
"foreach": {
"field": "tpA",
"ignore_missing": true,
"processor": {
"pipeline": {
"name": "react-v3-cms-tp-enrich"
}
}
}
},
{
"foreach": {
"field": "tpB",
"ignore_missing": true,
"processor": {
"pipeline": {
"name": "react-v3-cms-tp-enrich"
}
}
}
}
]
},
"docs": [
{
"_index": "react-v3-cms-stores",
"_source": {
"tpA": [
"Bqom9CUHSE"
],
"tpB": [
"CnLKuLGM8m"
],
"name": "Werk 1",
"identifier": "PROD_1",
"version": 28,
"createdAt": "2020-09-22T08:33:55.110Z",
"updatedAt": "2021-03-05T15:54:45.154Z",
"objectId": "k0xnrriDR5"
}
},
{
"_index": "react-v3-cms-stores",
"_source": {
"tpA": [],
"tpB": [
"TT96cE7tEh",
"XePVWmFA3y"
],
"name": "Porter",
"identifier": "PORTER",
"version": 69,
"createdAt": "2021-04-13T14:37:22.540Z",
"updatedAt": "2021-07-13T10:49:51.255Z",
"objectId": "v6pyKuWw14"
}
}
]
}
Output:
{
"docs" : [
{
"doc" : {
"_index" : "react-v3-cms-stores",
"_type" : "_doc",
"_id" : "_id",
"_source" : {
"identifier" : "PROD_1",
"createdAt" : "2020-09-22T08:33:55.110Z",
"tpA" : [
"Bqom9CUHSE"
],
"tpB" : [
"CnLKuLGM8m"
],
"templates" : [
"{name=Simple Com, type=tpA, objectId=Bqom9CUHSE}",
"{name=MQTT, type=tpB, objectId=CnLKuLGM8m}"
],
"name" : "Werk 1",
"version" : 28,
"objectId" : "k0xnrriDR5",
"updatedAt" : "2021-03-05T15:54:45.154Z"
},
"_ingest" : {
"_value" : null,
"timestamp" : "2021-07-20T09:17:03.409570925Z"
}
}
},
{
"doc" : {
"_index" : "react-v3-cms-stores",
"_type" : "_doc",
"_id" : "_id",
"_source" : {
"identifier" : "PORTER",
"createdAt" : "2021-04-13T14:37:22.540Z",
"tpA" : [ ],
"tpB" : [
"TT96cE7tEh",
"XePVWmFA3y"
],
"templates" : [
"{name=Paul, type=tpB, objectId=TT96cE7tEh}",
"{name=Tags, type=tpB, objectId=XePVWmFA3y}"
],
"name" : "Porter",
"version" : 69,
"objectId" : "v6pyKuWw14",
"updatedAt" : "2021-07-13T10:49:51.255Z"
},
"_ingest" : {
"_value" : null,
"timestamp" : "2021-07-20T09:17:03.409578492Z"
}
}
}
]
}
The referenced sub pipeline react-v3-cms-tp-enrich:
{
"description": "react-v3-cms-tp-enrich",
"processors": [
{
"set": {
"field": "tempId",
"value": "{{{_ingest._value}}}"
}
},
{
"enrich": {
"field": "tempId",
"ignore_missing": true,
"max_matches": "1",
"policy_name": "react-v3-cms-stores",
"target_field": "tempTp"
}
},
{
"append": {
"field": "templates",
"value": [
"{{{tempTp}}}"
]
}
},
{
"remove": {
"field": [
"tempId",
"tempTp"
],
"ignore_missing": true
}
}
]
}
The referenced enrich policy react-v3-cms-stores:
{
"match": {
"indices": "react-v3-cms-templates",
"match_field": "objectId",
"enrich_fields": ["type", "name"]
}
}
So the problem I'm having is, that as soon as I run an ingest into an index where 'templates' has a mapping to type 'nested', a mapper_parsing_error is thrown (see below). Type 'nested' is chosen in order for the template objects to be appended in the 'templates' field (array) as proper, searchable objects instead of flattened strings (as seen above).
{
"took" : 17,
"ingest_took" : 11,
"errors" : true,
"items" : [
{
"index" : {
"_index" : "react-v3-cms-stores",
"_type" : "_doc",
"_id" : "qChFw3oB7liRmCO0HSjD",
"status" : 400,
"error" : {
"type" : "mapper_parsing_exception",
"reason" : "object mapping for [templates] tried to parse field [null] as object, but found a concrete value"
}
}
},
...
]
}