# Ingest question - attachment processor plugin and dynamic fields

**URL:** <https://discuss.elastic.co/t/ingest-question-attachment-processor-plugin-and-dynamic-fields/92389>\
**Category:** Elasticsearch\
**Created:** [July 9, 2017, 11:13am UTC](https://discuss.elastic.co/t/ingest-question-attachment-processor-plugin-and-dynamic-fields/92389 "2017-07-09T11:13:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pnowy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pnowy/32/19868_2.png) [@pnowy](https://discuss.elastic.co/u/pnowy)\
**Post date:** [July 9, 2017, 11:13am UTC](https://discuss.elastic.co/t/ingest-question-attachment-processor-plugin-and-dynamic-fields/92389/1 "2017-07-09T11:13:39Z")

</div>

I have a question regarding the ingest attachment plugin (I would say it is question in general about ingest processor at all).

Let's assume that I have some kind of index:

```
PUT /myindex
{
  "mappings": {
    "mytype": {
      "properties": {
          "#id" : {"type": "long"}, 
          "myfield": {
              "type": "nested",
              "properties": {
                "name": { "type": "text" },
                "revision": {
                    "properties": {
                       "#data": { "type": "text" }
                    } 
                } 
              }
        }
      }
    }
  }
}

```

I am creating the indexes dynamically by application and the **_myfield_** could have different name defined by user in document definition. The internal structure of **_myfield_** will be always the same and the file data will be stored within **_revision_** field on the **_#data_** property (or it could be different unique name). The **_myfield_** and **_revision_** field will be arrays (by nested or by objects - I think it doesn't matter).

Example PUT:

```
PUT myindex/mytype/1?pipeline=attachment
{
    "#id" : 4,
    "myfield": [
        {
            "name": "the first one",
            "revision": [
                {
                    "#data": "e1xydGYxXGFuc2kNCkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0DQpccGFyIH0="        
                }
            ]
        }
   ]
}

```

Now I need to configure the ingest attachment processor plugin to detect by some pattern or some request dynamic parameters the name of **_myfield_**. I could have a couple of that kind of fields within my index with different name but the structure of that fil will be always the same.

```
PUT _ingest/pipeline/attachment
{
  "description" : "Extract attachment information from arrays",
  "processors" : [
    {
      "foreach": {
        "field": "*.revision", // does ingest support wilcard pattern or something like that (?)
        "processor": {
          "attachment": {
            "target_field": "_ingest._value.#attachment",
            "field": "_ingest._value.#data"
          }
        }
      }
    }
  ]
}

```

Additional question: how could I define the field (path) for nested fields for ingest processor? I was trying as usual the dot but for pipeline configuration I received exception (revision is not integer):

```
> PUT _ingest/pipeline/attachment
> {
> "description" : "Extract attachment information from arrays",
> "processors" : [
> {
> "foreach": {
> "field": "myfield.revision",
> "processor": {
> "attachment": {
> "target_field": "_ingest._value.attachment",
> "field": "_ingest._value.data"
> }
> }
> }
> }
> ]
> }

```

Thanks for help.

---

<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:** [August 6, 2017, 11:14am UTC](https://discuss.elastic.co/t/ingest-question-attachment-processor-plugin-and-dynamic-fields/92389/2 "2017-08-06T11:14:17Z")

</div>

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