# 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:** 1\
**Showing post:** 25

<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
			}
		}
	}
}
```

---

_[View the full topic](https://discuss.elastic.co/t/implementing-ingest-attachment-processor-plugin/52300)._
