# Nested attachments struggle

**URL:** <https://discuss.elastic.co/t/nested-attachments-struggle/104059>\
**Category:** Elasticsearch\
**Created:** [October 16, 2017, 8:04am UTC](https://discuss.elastic.co/t/nested-attachments-struggle/104059 "2017-10-16T08:04:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rutger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rutger/32/23075_2.png) [@Rutger](https://discuss.elastic.co/u/Rutger)\
**Post date:** [October 16, 2017, 8:04am UTC](https://discuss.elastic.co/t/nested-attachments-struggle/104059/1 "2017-10-16T08:04:57Z")

</div>

Hi there,

I'm having a (very) hard time mapping and indexing nested attachments. What I have so far:

Elasticsearch vesion: 5.5

Mapping:

```
{
    "mappings": {
        "entry": { 
            "properties": { 
                "id": { "type": "integer" }, 
                "title": { "type": "string" }, 
                "attachments": { 
                    "type" : "nested",
                    "properties": {
                        "attachment" : {
                            "type" : "attachment",
                            "fields" : {
                              "content" : { "index" : true },
                              "title" : { "store" : true },
                              "date" : { "store" : true },
                              "keywords" : { "store" : true },
                              "content_type" : { "store" : true },
                              "content_length" : { "store" : true },
                              "language" : { "store" : true }
                            }
                        }
                    }
                }
            }
        }
    }
}

```

Then I try to index a new entry using:

```
POST myindex/entry
{  
    "id": 1,
    "title": "Title here",
    "attachments": [
        {
            "content": "JVBERi0xLjcKJeLjz9....YKJSVFT0YK"
        } 
    ] 
}

```

It results in the error:

```
{
    "error": {
        "root_cause": [
            {
                "type": "illegal_argument_exception",
                "reason": "object mapping [attachments] can't be changed from nested to non-nested"
            }
        ],
        "type": "illegal_argument_exception",
        "reason": "object mapping [attachments] can't be changed from nested to non-nested"
    },
    "status": 400
}

```

What obvious thing am I missing here? Since the struggle is so hard and searching doesn't bring back much interesting results, it must be something simple right?

---

<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 16, 2017, 10:27am UTC](https://discuss.elastic.co/t/nested-attachments-struggle/104059/2 "2017-10-16T10:27:15Z")

</div>

Mapper attachment plugin is deprecated.

Use ingest attachment instead.

---

<div class="post-metadata">

**Author:** ![Rutger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rutger/32/23075_2.png) [@Rutger](https://discuss.elastic.co/u/Rutger)\
**Post date:** [October 17, 2017, 11:09am UTC](https://discuss.elastic.co/t/nested-attachments-struggle/104059/3 "2017-10-17T11:09:39Z")

</div>

Thanks for your reply. Appreciated. I didn't understood this from the (wealth) of documentation and Google searches. If I'd read with more attention I might have 🙂. But for me it was easily missed.

---

<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 17, 2017, 12:57pm UTC](https://discuss.elastic.co/t/nested-attachments-struggle/104059/4 "2017-10-17T12:57:19Z")

</div>

Sorry you missed it. We tried to make big but sometimes big is too big 😃

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/8/c/8cd8f763b409a102bb283efc7b5bf0cfcbe0f988.jpg)

I think but unsure though that mapper attachments should log something in the deprecated logger if activated. But nothing obvious for sure.

---

<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 14, 2017, 12:57pm UTC](https://discuss.elastic.co/t/nested-attachments-struggle/104059/5 "2017-11-14T12:57:28Z")

</div>

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