# Change mapping in pipeline for ingest-attachment plugin

**URL:** <https://discuss.elastic.co/t/change-mapping-in-pipeline-for-ingest-attachment-plugin/166071>\
**Category:** Elasticsearch\
**Created:** [January 29, 2019, 2:55am UTC](https://discuss.elastic.co/t/change-mapping-in-pipeline-for-ingest-attachment-plugin/166071 "2019-01-29T02:55:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ottadini](https://avatars.discourse-cdn.com/v4/letter/o/b19c9b/32.png) [@ottadini](https://discuss.elastic.co/u/ottadini)\
**Post date:** [January 29, 2019, 2:55am UTC](https://discuss.elastic.co/t/change-mapping-in-pipeline-for-ingest-attachment-plugin/166071/1 "2019-01-29T02:55:09Z")

</div>

I have a workflow for storing a range of binary document types (some handled by Tika, others that need pre-processing, with json generated in a script and indexed using PUT). For the documents handled by the ingest-attachment plugin, I want to 'flatten' the json for the document. Instead of having the "attachment" field with nested keys, I want it to be non-nested. So instead of something like this in the index results:

```
{
    "attachment": {
        "date": "2017-03-28T05:12:37Z",
        "content_type": "application/pdf",
        "language": "en",
        "content": "Text from PDF document"
    }
}

```

I would want something like this (with some of the field names changed):

```
{
    "ModDate": "2017-03-28T05:12:37Z",
    "content_type": "application/pdf",
    "language": "en",
    "content": "Text from PDF document"
}

```

How would I achieve this? Is there anything stupid about this idea that I've not realised?  
Can I change the mapping in the plugin's pipeline definition (I don't even know if this is the right terminology) or do I need to re index once indexed?

The requirement comes about because most of the documents that I'm indexing need pre-processing in closed-source software. I don't send the binary document to ES, rather just a json document with a set of common fields (the file metadata mostly), and any number of auto-generated fields.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 29, 2019, 4:06am UTC](https://discuss.elastic.co/t/change-mapping-in-pipeline-for-ingest-attachment-plugin/166071/2 "2019-01-29T04:06:45Z")

</div>

I believe that after the attachment processor you need to add the rename processor: [https://www.elastic.co/guide/en/elasticsearch/reference/6.5/rename-processor.html](https://www.elastic.co/guide/en/elasticsearch/reference/6.5/rename-processor.html)

---

<div class="post-metadata">

**Author:** ![ottadini](https://avatars.discourse-cdn.com/v4/letter/o/b19c9b/32.png) [@ottadini](https://discuss.elastic.co/u/ottadini)\
**Post date:** [January 31, 2019, 5:12am UTC](https://discuss.elastic.co/t/change-mapping-in-pipeline-for-ingest-attachment-plugin/166071/3 "2019-01-31T05:12:54Z")

</div>

Perfect, thank you.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 28, 2019, 5:12am UTC](https://discuss.elastic.co/t/change-mapping-in-pipeline-for-ingest-attachment-plugin/166071/4 "2019-02-28T05:12:58Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
