# Append processor overwrites, doesn't append

**URL:** <https://discuss.elastic.co/t/append-processor-overwrites-doesnt-append/169901>\
**Category:** Elasticsearch\
**Created:** [February 25, 2019, 8:26pm UTC](https://discuss.elastic.co/t/append-processor-overwrites-doesnt-append/169901 "2019-02-25T20:26:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![drs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drs/32/8001_2.png) [@drs](https://discuss.elastic.co/u/drs)\
**Post date:** [February 25, 2019, 8:26pm UTC](https://discuss.elastic.co/t/append-processor-overwrites-doesnt-append/169901/1 "2019-02-25T20:26:02Z")

</div>

I'm playing with the append processor, but it seems to be overwriting the array each time, not appending.

```auto
PUT /_ingest/pipeline/append
{
  "description": "Append",
  "processors": [
    {
      "append": {
        "field": "array",
        "value": [
          "{{value}}"
        ]
      }
    }
  ]
}

```

Then I test it out:

```auto
PUT localhost:9200/test/_doc/1?pipeline=append
{"value": 1}

```

\_source:

```auto
{
    "array": ["1"],
    "value": 1
}

```

Then,

```auto
PUT localhost:9200/test/_doc/1?pipeline=append
{"value": 2}

```

\_source:

```auto
{
    "array": ["2"],
    "value": 2
}

```

Shouldn't the result have `"array": ["1", "2"]`? If not, how is this append processor designed to be used?

---

<div class="post-metadata">

**Author:** ![gbrown](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gbrown/32/34482_2.png) [@gbrown](https://discuss.elastic.co/u/gbrown)\
**Post date:** [February 25, 2019, 9:54pm UTC](https://discuss.elastic.co/t/append-processor-overwrites-doesnt-append/169901/2 "2019-02-25T21:54:25Z")

</div>

The way the `append` processor works is that it appends the values in `value` to the field specified in `field`, and it operates independently on each document. So if I use the `_simulate` API:

```auto
POST _ingest/pipeline/append/_simulate
{
  "docs": [
    {
      "_source": {
        "value": 1,
        "array": [3,2]
      }
    },
    {
      "_source": {
        "value": 6,
        "array": [4,5]
      }
    }
  ]
}

```

I get back this result:

```auto
{
  "docs" : [
    {
      "doc" : {
        "_index" : "_index",
        "_type" : "_type",
        "_id" : "_id",
        "_source" : {
          "array" : [3, 2, "1"],
          "value" : 1
        },
        "_ingest" : {
          "timestamp" : "2019-02-25T21:51:30.282Z"
        }
      }
    },
    {
      "doc" : {
        "_index" : "_index",
        "_type" : "_type",
        "_id" : "_id",
        "_source" : {
          "array" : [4, 5, "6"],
          "value" : 6
        },
        "_ingest" : {
          "timestamp" : "2019-02-25T21:51:30.282Z"
        }
      }
    }
  ]
}

```

Does that help?

Edit to expand a bit: Since you're not providing an `array` field in the input documents, the processor is creating a new, empty array and appending `value` to that empty array.

---

<div class="post-metadata">

**Author:** ![drs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drs/32/8001_2.png) [@drs](https://discuss.elastic.co/u/drs)\
**Post date:** [February 26, 2019, 2:13am UTC](https://discuss.elastic.co/t/append-processor-overwrites-doesnt-append/169901/3 "2019-02-26T02:13:02Z")

</div>

Argh. That makes sense. Upon reading the description in the docs, I had hoped that each time you index the doc it appended the value to an array rather than overwriting it.

---

<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:** [March 26, 2019, 2:13am UTC](https://discuss.elastic.co/t/append-processor-overwrites-doesnt-append/169901/4 "2019-03-26T02:13:09Z")

</div>

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