# Implementing Ingest Attachment Processor Plugin

**URL:** <https://discuss.elastic.co/t/implementing-ingest-attachment-processor-plugin/52300>\
**Category:** Elasticsearch\
**Created:** [June 9, 2016, 8:35am UTC](https://discuss.elastic.co/t/implementing-ingest-attachment-processor-plugin/52300 "2016-06-09T08:35:27Z")\
**Posts on this page:** 15\
**Page:** 2

<div class="post-metadata">

**Author:** ![enolam](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/enolam/32/12958_2.png) [@enolam](https://discuss.elastic.co/u/enolam)\
**Post date:** [November 3, 2016, 7:39pm UTC](https://discuss.elastic.co/t/implementing-ingest-attachment-processor-plugin/52300/24 "2016-11-03T19:39:43Z")

</div>

@shradhatx I am with you. I am currently exploring Kibana as mentioned above by @shanec. The issue I am having now is querying the content field in the attachment. I also want to return highlights from the field as well. But since \_source is not searchable I dont know how properly set up my query.

---

<div class="post-metadata">

**Author:** ![enolam](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/enolam/32/12958_2.png) [@enolam](https://discuss.elastic.co/u/enolam)\
**Post date:** [November 3, 2016, 8:45pm UTC](https://discuss.elastic.co/t/implementing-ingest-attachment-processor-plugin/52300/25 "2016-11-03T20:45:43Z")

</div>

So, my issue has been solved. Thanks to @shanec for the help and mentioning Kibana.

For the sake of brevity, my working solution is below. I'm sure this can be optimized, but for now it gets the job done.

```
DELETE /myindex
PUT /myindex
{
	"mappings": {
		"document": {
			"properties": {
				"thedata": {
					"type": "text"
				},
				"title": {
					"type": "text"
				},
				"location": {
					"type": "text"
				}
			}
		}
	}
}

DELETE _ingest/pipeline/attachment
PUT _ingest/pipeline/attachment
{
  "description": "Process documents",
  "processors": [
    {
      "attachment": {
        "field": "thedata",
        "indexed_chars": -1
      }
    },
    {
      "set": {
        "field": "attachment.title",
        "value": "{{ title }}"
      }
    },
    {
      "set": {
        "field": "attachment.location",
        "value": "{{ location }}"
        }
    },
    {
      "remove": { "field": "thedata" }
    },
    {
      "remove": { "field": "title" }
    },
    {
      "remove": { "field": "location" }
    }
  ]
}

PUT /_bulk?pipeline=attachment
{"index": {"_index": "myindex", "_type" : "document", "_id" : "2" }}
{"thedata": "dGVzdGluZyBteSBmaXJzdCBlbmNvZGVkIHRleHQ=", "title": "testfile.docx", "location": "righthere"}

GET /myindex/document/2

GET /myindex/_search
{
	"query": {
	  "match": {
		  "attachment.content": "testing"
    }
  },
	"highlight": {
		"fields": {
			"attachment.content": {
				"fragment_size": 150,
				"number_of_fragments": 3,
				"no_match_size": 150
			}
		}
	}
}
```

---

<div class="post-metadata">

**Author:** ![shradhatx](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shradhatx/32/45398_2.png) [@shradhatx](https://discuss.elastic.co/u/shradhatx)\
**Post date:** [November 3, 2016, 10:10pm UTC](https://discuss.elastic.co/t/implementing-ingest-attachment-processor-plugin/52300/26 "2016-11-03T22:10:47Z")

</div>

Or alternately you could do this-  
DELETE /myindex  
PUT /myindex  
PUT /myindex/mytype/\_mapping  
{  
"mytype": {  
"properties": {  
"attachment": {  
"properties": {  
"content": {  
"type": "text",  
"term\_vector":"with\_positions\_offsets",  
"store": true  
}

```
              }
           }
}
}

```

}

PUT myindex/mytype/1?pipeline=attachment  
{  
"data": "e1xydGYxXGFuc2kNCkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0DQpccGFyIH0="  
}

GET /myindex/mytype/\_search  
{  
"stored\_fields": [],  
"query": {  
"match":{"attachment.content": "ipsum"}  
},  
"highlight": {  
"fields": {  
"attachment.content": {  
}  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![evert](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/evert/32/8143_2.png) [@evert](https://discuss.elastic.co/u/evert)\
**Post date:** [December 17, 2016, 1:28pm UTC](https://discuss.elastic.co/t/implementing-ingest-attachment-processor-plugin/52300/28 "2016-12-17T13:28:45Z")

</div>

Did you install the ingest attachment plugin?

---

<div class="post-metadata">

**Author:** ![Celia\_Tang](https://avatars.discourse-cdn.com/v4/letter/c/e9a140/32.png) [@Celia\_Tang](https://discuss.elastic.co/u/Celia_Tang)\
**Post date:** [June 28, 2017, 8:46pm UTC](https://discuss.elastic.co/t/implementing-ingest-attachment-processor-plugin/52300/30 "2017-06-28T20:46:59Z")

</div>

I have a problem too. I'm trying to index a pdf, and I have installed the ingest attachment. But when I try to PUT my pdf, it returns an error that says that content-type [application/pdf] is not supported

---

<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:** [June 28, 2017, 9:00pm UTC](https://discuss.elastic.co/t/implementing-ingest-attachment-processor-plugin/52300/31 "2017-06-28T21:00:46Z")

</div>

Open your own question. This one is too old.

BTW read the documentation and you will see you can't upload directly a PDF.

---

<div class="post-metadata">

**Author:** ![Celia\_Tang](https://avatars.discourse-cdn.com/v4/letter/c/e9a140/32.png) [@Celia\_Tang](https://discuss.elastic.co/u/Celia_Tang)\
**Post date:** [June 28, 2017, 9:03pm UTC](https://discuss.elastic.co/t/implementing-ingest-attachment-processor-plugin/52300/32 "2017-06-28T21:03:08Z")

</div>

Which documentation? And how do I open my own question?

---

<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:** [June 29, 2017, 5:58am UTC](https://discuss.elastic.co/t/implementing-ingest-attachment-processor-plugin/52300/33 "2017-06-29T05:58:39Z")

</div>

> And how do I open my own question?

[https://discuss.elastic.co/c/elasticsearch](https://discuss.elastic.co/c/elasticsearch)

Click on "new topic"

> Which documentation?

> **[Ingest Attachment plugin | Elasticsearch Plugins and Integrations \[8.11\] |...](https://www.elastic.co/guide/en/elasticsearch/plugins/current/ingest-attachment.html)**

---

<div class="post-metadata">

**Author:** ![pnowy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pnowy/32/19868_2.png) [@pnowy](https://discuss.elastic.co/u/pnowy)\
**Post date:** [July 8, 2017, 10:11am UTC](https://discuss.elastic.co/t/implementing-ingest-attachment-processor-plugin/52300/34 "2017-07-08T10:11:18Z")

</div>

@dadoonet I have a question regarding attachment data (base64 encoded binary saved on field). Is it possible to exclude that data from elasticsearch? From my perspective it doesn't make sense to keep binary data on the ES because the ES is never the source of truth regarding the data and the files are kept separately somewhere. Is there a possibility to exclude that and save only retrieved content?

Thanks!

---

<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:** [July 8, 2017, 11:23am UTC](https://discuss.elastic.co/t/implementing-ingest-attachment-processor-plugin/52300/35 "2017-07-08T11:23:35Z")

</div>

Open your own question in #elasticsearch. This one is too old.  
But you can link to this one if needed.

I believe you are asking about the `mapper-attachments` plugin, right?

First, be aware that this plugin has been deprecated in 5.0.0 and is now removed in 6.0.  
If you are starting a project, don't use it!

Use `ingest-attachment` instead: [https://www.elastic.co/guide/en/elasticsearch/plugins/current/ingest-attachment.html](https://www.elastic.co/guide/en/elasticsearch/plugins/current/ingest-attachment.html)

In the pipeline, just add a `remove` processor to remove the BASE64 content.

In the context of mapper-attachments, you can may be use source exclude feature. [https://www.elastic.co/guide/en/elasticsearch/reference/5.5/mapping-source-field.html#include-exclude](https://www.elastic.co/guide/en/elasticsearch/reference/5.5/mapping-source-field.html#include-exclude)

---

<div class="post-metadata">

**Author:** ![pnowy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pnowy/32/19868_2.png) [@pnowy](https://discuss.elastic.co/u/pnowy)\
**Post date:** [July 8, 2017, 12:17pm UTC](https://discuss.elastic.co/t/implementing-ingest-attachment-processor-plugin/52300/36 "2017-07-08T12:17:48Z")

</div>

Thanks. I was asking about the ingest-attachment. That is everything what I've needed to know.

---

<div class="post-metadata">

**Author:** ![pnowy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pnowy/32/19868_2.png) [@pnowy](https://discuss.elastic.co/u/pnowy)\
**Post date:** [July 9, 2017, 11:15am UTC](https://discuss.elastic.co/t/implementing-ingest-attachment-processor-plugin/52300/37 "2017-07-09T11:15:03Z")

</div>

Hi @dadoonet . I've created separate question about different case - the support of some kind of dynamic fields for ingest processor.

> [@Ingest question - attachment processor plugin and dynamic fields](https://discuss.elastic.co/t/ingest-question-attachment-processor-plugin-and-dynamic-fields/92389):
>
> I have a question regarding the ingest attachment plugin (I would say it is question in general about ingest processor at all). Let's assume that I have some kind of index: PUT /myindex { "mappings": { "mytype": { "properties": { "#id" : {"type": "long"}, "myfield": { "type": "nested", "properties": { "name": { "type": "text" }, "revision": { "properties": { …

---

<div class="post-metadata">

**Author:** ![Sudhanshu\_Sekhar\_Gou](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@Sudhanshu\_Sekhar\_Gou](https://discuss.elastic.co/u/Sudhanshu_Sekhar_Gou)\
**Post date:** [March 14, 2018, 11:15am UTC](https://discuss.elastic.co/t/implementing-ingest-attachment-processor-plugin/52300/38 "2018-03-14T11:15:29Z")

</div>

This is fine. I have done till this.  
How can I choose a pdf file for indexing?  
I mean to say...How will I specify the pdf file path for indexing?

---

<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:** [March 14, 2018, 1:51pm UTC](https://discuss.elastic.co/t/implementing-ingest-attachment-processor-plugin/52300/39 "2018-03-14T13:51:47Z")

</div>

@Sudhanshu_Sekhar_Gou Please open your own question.  
This one is too old and should have been closed.

You can link to it in your own post though.

---

<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:** [March 14, 2018, 5:00pm UTC](https://discuss.elastic.co/t/implementing-ingest-attachment-processor-plugin/52300/40 "2018-03-14T17:00:00Z")

</div>

This topic was automatically closed after 3 hours. New replies are no longer allowed.

[Previous page](https://discuss.elastic.co/t/implementing-ingest-attachment-processor-plugin/52300.md?page=1)
