# Using Transform for document count when document updated

**URL:** https://discuss.elastic.co/t/using-transform-for-document-count-when-document-updated/364924
**Category:** Elasticsearch
**Tags:** transforms
**Created:** [August 14, 2024, 5:31pm UTC](https://discuss.elastic.co/t/using-transform-for-document-count-when-document-updated/364924 "2024-08-14T17:31:03Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![Patrick\_Whelan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/patrick_whelan/32/135049_2.png) [@Patrick\_Whelan](https://discuss.elastic.co/u/Patrick_Whelan)
#### Post date: [August 14, 2024, 6:48pm UTC](https://discuss.elastic.co/t/using-transform-for-document-count-when-document-updated/364924/2 "2024-08-14T18:48:53Z")

</div>

> Is the above understanding is correct - transform will not delete {status : "new",count : "1"} from transform dest index in above senario?

This is correct.

> like add an field indicating when the transform result is generated/updated

This other answer may help - [Creating an ingest pipeline for transforms](https://discuss.elastic.co/t/transform-results-in-index-with-missing-documents-when-using-the-api-but-works-for-console/363044/9).

- create an ingest pipeline that adds a timestamp field
- use the [Put Transform](https://www.elastic.co/guide/en/elasticsearch/reference/current/put-transform.html) API to set the pipeline in the `dest.pipeline` field

Any document added or updated in the destination index will get a new timestamp.

It would look something like:

```auto
PUT _ingest/pipeline/pipeline_add_ingest_timestamp
{ 
  "description": "Adds event.ingested field which represents time of ingestion.",
  "processors": [
    {
      "set": {
        "field": "event.ingested",
        "value": "{{_ingest.timestamp}}"
      }
    }
  ]
}

```

```auto
PUT _transform/new_orders_count
{
  ...
  "dest": {
    "index": "dest_index_name",
    "pipeline": "pipeline_add_ingest_timestamp"
  },
  ...
}

```

---

_[View the full topic](https://discuss.elastic.co/t/using-transform-for-document-count-when-document-updated/364924)._
