Q:

Modifying the content of a ingested pdf

I have a pipeline created in elasticsearch that ingests a document with an array of pdfs. I want to modify the content field in order to concatenate other fields at the end for searching purposes.
My pipeline is: 
client.ingest.putPipeline({
  id: 'my-pipeline-id',
  body: {
    "description" : "Extract attachment information",
    "processors" : 
    [
      {
        "foreach": {
          "field": "attachments",
          "processor": {
            "attachment": {
              "target_field": "_ingest._value.attachment",
              "field": "_ingest._value.data"
            }
          }
        }
      }
    ]
  }
}, callback);

I can't add a set processor after the foreach, because I need to access the content of every pdf in order to put the values of that document at the end of the content.
Some example documents are:
let doc = {
    matricula: '6789AAA',
    bastidor: 'BASTIDOR789',
    expediente: '79',
    attachments:
    [
        {
            filename: "informe",
            data: /* chunk of data in base64 */
        },
        {
            filename: "ivtm_diba",
            data: /* another chunk of data in base64 */
        }
    ]
};

The result document will look like this:
{
    "_index": "doc",
    "_type": "document",
    "_id": "AVsy85rwMuPe74hQBT8L",
    "_score": 1.2039728,
    "_source": {
      "attachments": [
        {
          "filename": "informe",
          "attachment": {
            "Very very long content",
            "date": "2016-06-08T14:01:25Z",
            "content_type": "application/pdf",
            "language": "es",
            "content_length": 3124
          }
        },
        {
          "filename": "ivtm_diba",
          "attachment": {
            "content": "Very long content here",
            "content_type": "application/pdf",
            "language": "ca",
            "content_length": 5657
          }
        }
      ],
      "expediente": "79",
      "matricula": "6789ZXC",
      "bastidor": "BASTIDOR789"
    }
  }

And I want to add to the content field the values of "bastidor", "matricula" and "expediente" fields.
I'm using elasticsearch-js but that's not a requirement.

A:

The elasticsearch _all field can be used in most cases like this.  

