# Defining Elasticsearch mapping for ingest-attachment inner field

**URL:** <https://discuss.elastic.co/t/defining-elasticsearch-mapping-for-ingest-attachment-inner-field/87533>\
**Category:** Elasticsearch\
**Created:** [May 30, 2017, 9:16am UTC](https://discuss.elastic.co/t/defining-elasticsearch-mapping-for-ingest-attachment-inner-field/87533 "2017-05-30T09:16:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tflorac](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tflorac/32/42393_2.png) [@tflorac](https://discuss.elastic.co/u/tflorac)\
**Post date:** [May 30, 2017, 9:16am UTC](https://discuss.elastic.co/t/defining-elasticsearch-mapping-for-ingest-attachment-inner-field/87533/1 "2017-05-30T09:16:52Z")

</div>

I'm trying to build an application using an Elasticsearch index. I have several "inner" fields which can contain binary data (mainly PDF), and I'm looking for the best way to define my pipeline and mapping, given the facts that:

- all fields and contents can be provided in several languages (french and english) and in several fields
- I have to be able to query contents for a given language and/or for a given field.

This is how I defined my mapping until now:

```
{
    "WfNewsEvent": {
        "properties": {
            "title": {
                "type": "object",
                "properties": {
                    "en": {
                        "type": "string"
                    },
                    "fr": {
                        "type": "string",
                        "analyzer": "french",
                        "search_analyzer": "french_search"
                    }
                }
            },
            ...
            "extfile": {
                "type": "object",
                "properties": {
                    "title": {
                        "type": "object",
                        "properties": {
                            "en": {
                                "type": "string"
                            },
                            "fr": {
                                "type": "string",
                                "analyzer": "french",
                                "search_analyzer": "french_search"
                            }
                        }
                    },
                    "description": {
                        "type": "object",
                        "properties": {
                            "en": {
                                "type": "string"
                            },
                            "fr": {
                                "type": "string",
                                "analyzer": "french",
                                "search_analyzer": "french_search"
                            }
                        }
                    },
                    "data": {
                        "type": "object",
                        "properties": {
                            "en": {
                                "type": "attachment"
                            },
                            "fr": {
                                "type": "attachment",
                                "analyzer": "french",
                                "search_analyzer": "french_search"
                            }
                        }
                    }
                }
            },
            "gallery": {
                "type": "object",
                "properties": {
                    "title": {
                        "type": "object",
                        "properties": {
                            "en": {
                                "type": "string"
                            },
                            "fr": {
                                "type": "string",
                                "analyzer": "french",
                                "search_analyzer": "french_search"
                            }
                        }
                    },
                    "description": {
                        "type": "object",
                        "properties": {
                            "en": {
                                "type": "string"
                            },
                            "fr": {
                                "type": "string",
                                "analyzer": "french",
                                "search_analyzer": "french_search"
                            }
                        }
                    },
                    "data": {
                        "type": "object",
                        "properties": {
                            "en": {
                                "type": "attachment"
                            },
                            "fr": {
                                "type": "attachment",
                                "analyzer": "french",
                                "search_analyzer": "french_search"
                            }
                        }
                    }
                }
            }
        }
    }
}

```

Then my 'attachment' pipeline definition:

```
{
  "description" : "Extract attachment information",
  "processors" : [
    {
      "attachment" : {
        "field" : "extfile.data.en",
        "ignore_missing": true
      }
    },
    {
      "attachment" : {
        "field" : "extfile.data.fr",
        "ignore_missing": true
      }
    },
    {
      "attachment" : {
        "field" : "gallery.data.fr",
        "ignore_missing": true
      }
    },
    {
      "attachment" : {
        "field" : "gallery.data.fr",
        "ignore_missing": true
      }
    }
  ]
}

```

Actually when I'm trying to index a document, ES raises an exception saying that "data" is not an integer. So any help would be greatly welcome!

Best regards,  
Thierry

---

<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 1, 2017, 4:07pm UTC](https://discuss.elastic.co/t/defining-elasticsearch-mapping-for-ingest-attachment-inner-field/87533/2 "2017-06-01T16:07:16Z")

</div>

You should not use the mapper attachments plugin anymore as it has been deprecated and will be removed in 6.0.

Use only ingest-attachment instead.

So basically don't use:

```auto
"type": "attachment"

```

---

<div class="post-metadata">

**Author:** ![tflorac](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tflorac/32/42393_2.png) [@tflorac](https://discuss.elastic.co/u/tflorac)\
**Post date:** [June 4, 2017, 8:33am UTC](https://discuss.elastic.co/t/defining-elasticsearch-mapping-for-ingest-attachment-inner-field/87533/3 "2017-06-04T08:33:57Z")

</div>

Hi David,  
I finally made the ingest-attachment plug-in work...  
But I wanted to handle the "attachment" property as an inner object property (like "[extfile.data.fr](http://extfile.data.fr)") but the only solution I found until now was to make my "attachment" property a first-level one.  
Is there a solution to define ingest-attachment pipeline for inner properties?

---

<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 4, 2017, 12:04pm UTC](https://discuss.elastic.co/t/defining-elasticsearch-mapping-for-ingest-attachment-inner-field/87533/4 "2017-06-04T12:04:22Z")

</div>

Yes. This should work on inner fields.

Do you have a full non working example ?

---

<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:** [July 2, 2017, 12:04pm UTC](https://discuss.elastic.co/t/defining-elasticsearch-mapping-for-ingest-attachment-inner-field/87533/5 "2017-07-02T12:04:23Z")

</div>

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