I am trying to use an enrich policy to match on a filename and return the _id fields of that doc to add in as a field in my secondary index. I have two indexes the first has 1 entry with field 'filename'. The second index uses a pipeline and enrich policy shown below to match on the filename and return the _id value of the first index entry as a field in the second index. This does not work the _id value is not returned as expected.
Any clues as to why this is?
{
"description": "x",
"processors": [
{
"set": {
"field": "test",
"value": "null"
}
},
{
"enrich": {
"policy_name": "enrich-policy",
"field": "filename",
"target_field": "tmp",
"max_matches": "1",
"ignore_failure": true
}
},
{
"set": {
"if": "ctx.containsKey('tmp')",
"field": "test",
"value": "{{tmp._id}}",
"on_failure":[{
"set":{
"field":"test",
"value":"!Issue setting field value!"
}
}]
}
},
{
"remove": {
"field": ["tmp"],
"ignore_failure": true
}
}
],
"version": 1
}
enrich-policy.json
{
"match": {
"indices": ["index-1"],
"match_field": "filename",
"enrich_fields": ["_id"]
}
}