# Ingest attachment plugin, 2 fields with content - one encoded and one decoded

**URL:** <https://discuss.elastic.co/t/ingest-attachment-plugin-2-fields-with-content-one-encoded-and-one-decoded/100213>\
**Category:** Elasticsearch\
**Created:** [September 12, 2017, 12:56pm UTC](https://discuss.elastic.co/t/ingest-attachment-plugin-2-fields-with-content-one-encoded-and-one-decoded/100213 "2017-09-12T12:56:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mbedna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mbedna/32/21488_2.png) [@mbedna](https://discuss.elastic.co/u/mbedna)\
**Post date:** [September 12, 2017, 12:56pm UTC](https://discuss.elastic.co/t/ingest-attachment-plugin-2-fields-with-content-one-encoded-and-one-decoded/100213/1 "2017-09-12T12:56:43Z")

</div>

Is it necessary to have content of pdf file in 2 fields in Elastic while using ingest attachment plugin?

Example:

"data": "JVBERi0xLjUNCiW1tbW1DQoxIDA

"attachment": {  
"content\_type": "application/pdf",  
"author": "Sample",  
"language": "en",  
"title": "Title",  
"content": """Some Content

Content of file is in data field (base64 encoded) and data field is used to fill content field (decoded string).  
Can I have just one field content with decoded string?

---

<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:** [September 12, 2017, 2:16pm UTC](https://discuss.elastic.co/t/ingest-attachment-plugin-2-fields-with-content-one-encoded-and-one-decoded/100213/2 "2017-09-12T14:16:46Z")

</div>

No. It's better to remove the original field `data` IMO.

---

<div class="post-metadata">

**Author:** ![mbedna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mbedna/32/21488_2.png) [@mbedna](https://discuss.elastic.co/u/mbedna)\
**Post date:** [September 12, 2017, 4:25pm UTC](https://discuss.elastic.co/t/ingest-attachment-plugin-2-fields-with-content-one-encoded-and-one-decoded/100213/3 "2017-09-12T16:25:33Z")

</div>

Does it have to be 2 step process?

1. Set base64 encoded data field and index document with ?pipeline=attachment in URL. Language, author, content\_length and content fields will be generated based on data field.
2. Update document with data=null.

---

<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:** [September 12, 2017, 5:03pm UTC](https://discuss.elastic.co/t/ingest-attachment-plugin-2-fields-with-content-one-encoded-and-one-decoded/100213/4 "2017-09-12T17:03:29Z")

</div>

Yes. It needs 2 steps.

> <https://github.com/elastic/elasticsearch/issues/25441>

You can use the `remove` processor BTW: [https://www.elastic.co/guide/en/elasticsearch/reference/current/remove-processor.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/remove-processor.html)

---

<div class="post-metadata">

**Author:** ![mbedna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mbedna/32/21488_2.png) [@mbedna](https://discuss.elastic.co/u/mbedna)\
**Post date:** [September 13, 2017, 7:32am UTC](https://discuss.elastic.co/t/ingest-attachment-plugin-2-fields-with-content-one-encoded-and-one-decoded/100213/5 "2017-09-13T07:32:52Z")

</div>

I use attachment processor in foreach loop so I added second foreach loop with remove processor in processors section and this worked like a charm 😃

Thank you for your help!

---

<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:** [October 11, 2017, 7:33am UTC](https://discuss.elastic.co/t/ingest-attachment-plugin-2-fields-with-content-one-encoded-and-one-decoded/100213/6 "2017-10-11T07:33:10Z")

</div>

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