# Ingest attachment in nested type

**URL:** <https://discuss.elastic.co/t/ingest-attachment-in-nested-type/226014>\
**Category:** Elasticsearch\
**Created:** [April 1, 2020, 9:24am UTC](https://discuss.elastic.co/t/ingest-attachment-in-nested-type/226014 "2020-04-01T09:24:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattiacareddu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattiacareddu/32/60917_2.png) [@mattiacareddu](https://discuss.elastic.co/u/mattiacareddu)\
**Post date:** [April 1, 2020, 9:24am UTC](https://discuss.elastic.co/t/ingest-attachment-in-nested-type/226014/1 "2020-04-01T09:24:15Z")

</div>

Hi,  
I'm trying to index multiple documents in nested type using ingest attachment plugin.  
Simply I create my pipeline as follow:

```
{
    "description": "Extract attachment information",
    "processors": [
        {
            "foreach": {
                "field": "data",
                "processor": {
                  "attachment": {
                    "field": "_ingest._value",
                    "ignore_failure" : true
                  }
                }
            }
        }
    ]
}

```

Then I index my document as follow:

```
PUT /test_ingest/_doc/1?pipeline=attachment
{
  "data": ["e1xydGYxXGFuc2kNCkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0DQpccGFyIH0=", "Y2lhb25lZWUhCg=="]
}

```

But as result I get:

```
"_source" : {
    "data" : [
      "e1xydGYxXGFuc2kNCkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0DQpccGFyIH0=",
      "dGVzdCEK"
    ],
    "attachment" : {
      "content_type" : "text/plain; charset=ISO-8859-1",
      "language" : "et",
      "content" : "test!",
      "content_length" : 7
    }
  }

```

Instead of getting an array of attachments.  
I also tried to create a mapping as follow:

```
"attachments": {
    "type": "nested",
    "properties": {
        "content_type": {
            "type": "keyword"
        },
        "language": {
            "type": "keyword"
        },
        "content": {
            "type": "text"
        },
        "content_length": {
            "type": "integer"
        }
    }
}

```

and specify the target field in my pipeline:

```
{
    "description": "Extract attachment information",
    "processors": [
        {
            "foreach": {
                "field": "data",
                "processor": {
                  "attachment": {
                    "field": "_ingest._value",
                    "target_field": "attachments",
                    "ignore_failure" : true
                  }
                }
            }
        }
    ]
}

```

Unluckily I don't have any success. I also try to simulate the pipeline and it gives as result only one attachment instead of an array as expected by using foreach processor.

Any suggestions?

---

<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:** [April 1, 2020, 9:35am UTC](https://discuss.elastic.co/t/ingest-attachment-in-nested-type/226014/2 "2020-04-01T09:35:40Z")

</div>

Did you see [https://www.elastic.co/guide/en/elasticsearch/plugins/7.6/ingest-attachment-with-arrays.html](https://www.elastic.co/guide/en/elasticsearch/plugins/7.6/ingest-attachment-with-arrays.html) ?

---

<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:** [April 29, 2020, 9:35am UTC](https://discuss.elastic.co/t/ingest-attachment-in-nested-type/226014/3 "2020-04-29T09:35:49Z")

</div>

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