# Problem with Ingest Attachment Processor Plugin

**URL:** <https://discuss.elastic.co/t/problem-with-ingest-attachment-processor-plugin/105573>\
**Category:** Elasticsearch\
**Created:** [October 27, 2017, 12:59pm UTC](https://discuss.elastic.co/t/problem-with-ingest-attachment-processor-plugin/105573 "2017-10-27T12:59:17Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomky](https://avatars.discourse-cdn.com/v4/letter/t/bbce88/32.png) [@tomky](https://discuss.elastic.co/u/tomky)\
**Post date:** [October 27, 2017, 12:59pm UTC](https://discuss.elastic.co/t/problem-with-ingest-attachment-processor-plugin/105573/1 "2017-10-27T12:59:17Z")

</div>

Hi!  
I am new to this plugin and need your help.

This is what I do:

1. Create index:

```
PUT localhost:9200/myindex
```

1. And mappings:

```
PUT localhost:9200/myindex/mytype/_mapping
{
	"messages": {
	  "properties": {
		"subject": {"type": "string"},
		"sender": {"type": "string"},
		"receiver": {"type": "string"},
		"body": {"type": "text"}
	  }
	}
}
```

1. Now I create attachment by:

```
PUT http://localhost:9200/_ingest/pipeline/attachment
{
   "description" : "Extract attachment information",
   "processors" : [
   {
	   "attachment" : {
			"field" : "data",
			"indexed_chars" : -1
		}
   }]
}
```

1. I add some data and it works fine with searching etc.

2. But when I add an attachment to my previously added data like this:

```
PUT http://localhost:9200/myindex/mytype/1?pipeline=attachment
{
	"data": "some base64 data"
}
```

Then it overrides my whole previuosly added data and I am unable to search in my index.

What am I doing wrong? Please help.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [October 27, 2017, 3:40pm UTC](https://discuss.elastic.co/t/problem-with-ingest-attachment-processor-plugin/105573/2 "2017-10-27T15:40:21Z")

</div>

Hey,

you need to supply the full document here and not just the field you want to add, when you use the [Index API](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/docs-index_.html)

--Alex

---

<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:** [October 27, 2017, 3:42pm UTC](https://discuss.elastic.co/t/problem-with-ingest-attachment-processor-plugin/105573/3 "2017-10-27T15:42:37Z")

</div>

Ingest plugin does not support partial updates. So you need to provide the full JSON document:

```auto
{
  "data": "BASE64 HERE",
  "subject": "foo",
  "sender": "foo",
  "body": "foo"
}

```

PS: note that you should use `text` in your mapping and not `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:** [October 27, 2017, 3:43pm UTC](https://discuss.elastic.co/t/problem-with-ingest-attachment-processor-plugin/105573/4 "2017-10-27T15:43:24Z")

</div>

Sounds like @spinscale beat me on that one! 😛

---

<div class="post-metadata">

**Author:** ![tomky](https://avatars.discourse-cdn.com/v4/letter/t/bbce88/32.png) [@tomky](https://discuss.elastic.co/u/tomky)\
**Post date:** [October 27, 2017, 3:57pm UTC](https://discuss.elastic.co/t/problem-with-ingest-attachment-processor-plugin/105573/5 "2017-10-27T15:57:04Z")

</div>

OMG! So simple 🙂

---

<div class="post-metadata">

**Author:** ![tomky](https://avatars.discourse-cdn.com/v4/letter/t/bbce88/32.png) [@tomky](https://discuss.elastic.co/u/tomky)\
**Post date:** [October 27, 2017, 3:58pm UTC](https://discuss.elastic.co/t/problem-with-ingest-attachment-processor-plugin/105573/6 "2017-10-27T15:58:17Z")

</div>

Why should I use `text`?

---

<div class="post-metadata">

**Author:** ![tomky](https://avatars.discourse-cdn.com/v4/letter/t/bbce88/32.png) [@tomky](https://discuss.elastic.co/u/tomky)\
**Post date:** [October 27, 2017, 5:46pm UTC](https://discuss.elastic.co/t/problem-with-ingest-attachment-processor-plugin/105573/7 "2017-10-27T17:46:40Z")

</div>

When I want to use pipeline in PHP what should I do?  
Code below doesn't work:

```
$params = [
    'index' => 'myindex',
    'type' => 'mytype',
    'id' => '1',
    'body' => [
		'data' => 'BASE64_DATA',
		'subject' => 'test',
		'sender' => 'test',
		'body' => 'test',
	],
];
$client->ingest()->putPipeline($params);
```

---

<div class="post-metadata">

**Author:** ![tomky](https://avatars.discourse-cdn.com/v4/letter/t/bbce88/32.png) [@tomky](https://discuss.elastic.co/u/tomky)\
**Post date:** [October 27, 2017, 6:00pm UTC](https://discuss.elastic.co/t/problem-with-ingest-attachment-processor-plugin/105573/8 "2017-10-27T18:00:13Z")

</div>

I found a solution.  
I have to use 'pipeline' =\> 'attachment' in my $params and then index it normally.

---

<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:** [November 24, 2017, 6:00pm UTC](https://discuss.elastic.co/t/problem-with-ingest-attachment-processor-plugin/105573/9 "2017-11-24T18:00:50Z")

</div>

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