Hi
I'm a beginner to Elasticsearch, so maybe this is simple to solve, but I haven't found a solution to my problem:
I have an object with an array containing attachment data, and I want to be able to append new data to this array. I know how to use the ingest plugin to retrieve the data out of attachments, and I know how to append to an array, but I cannot get both to work in a single step. Could someone help me? I'd be happy about any hint!
My current procedure is...suboptimal - for completeness, however:
- Create a temporary index, where the data of an ingested attachment is stored
- I have a processor for the attachments
"processors": [
{
"foreach": {
"field": "Attachments",
"processor": {
"attachment": {
"target_field": "_ingest._value.attachment",
"field": "_ingest._value.data"
}
}
}
},
{
"foreach": {
"field": "Attachments",
"processor": {
"remove": {
"field": "_ingest._value.data"
}
}
}
}
]
- and post it to
/tmpattachments/_doc/randomid?pipeline=Attachments
- Recover the extracted information
- Just use a get on the randomid generated in step 1.
- Again send this information to Elasticsearch, and this time use a script, to append it to the array AttachedFiles, where it should go:
"script": {
"source": "ctx._source.AttachedFiles.addAll(params.new)"
"params": {
"new": [
{
"Content": "extracted info",
"Filename": "file.pdf"
}
]
},
}
- post it to
/finaldestination/_update/123
- Delete the temporary attachment object from step 1.