# Automatic copying of document

**URL:** <https://discuss.elastic.co/t/automatic-copying-of-document/257687>\
**Category:** Elasticsearch\
**Created:** [December 4, 2020, 5:37pm UTC](https://discuss.elastic.co/t/automatic-copying-of-document/257687 "2020-12-04T17:37:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pskhanapur](https://avatars.discourse-cdn.com/v4/letter/p/dfb087/32.png) [@pskhanapur](https://discuss.elastic.co/u/pskhanapur)\
**Post date:** [December 4, 2020, 5:37pm UTC](https://discuss.elastic.co/t/automatic-copying-of-document/257687/1 "2020-12-04T17:37:43Z")

</div>

I have two indices, let's say

- index1
- index2 (clone of index1)

I always write documents to index1.  
Is there a way to automatically trigger a copy of the document from index1 to index2, every time I write a document into the index1?

---

<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:** [December 4, 2020, 11:01pm UTC](https://discuss.elastic.co/t/automatic-copying-of-document/257687/2 "2020-12-04T23:01:41Z")

</div>

That might be doable with this:

> **[Cross-cluster replication | Elasticsearch Reference \[7.10\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/xpack-ccr.html)**

Not sure though as it's normally made to replicate to another cluster. Also it requires a platinum license or a trial.

What about solving that problem from the application which writes the data to elasticsearch?

Otherwise a snapshot and restore with rename?

---

<div class="post-metadata">

**Author:** ![pskhanapur](https://avatars.discourse-cdn.com/v4/letter/p/dfb087/32.png) [@pskhanapur](https://discuss.elastic.co/u/pskhanapur)\
**Post date:** [December 4, 2020, 11:52pm UTC](https://discuss.elastic.co/t/automatic-copying-of-document/257687/3 "2020-12-04T23:52:31Z")

</div>

Thanks David. Yes, application writing into both indices is easiest way to do this.  
Actually, my original problem is that, I want to create two index pattern for the same data. I have two separate timestamps in my data and I want to visualize my data based on two different time filters. I couldn't do that. So I'm creating clone of the data and then using a second time filter field on the cloned data.

---

<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:** [December 7, 2020, 3:49pm UTC](https://discuss.elastic.co/t/automatic-copying-of-document/257687/4 "2020-12-07T15:49:24Z")

</div>

> [@pskhanapur](#):
>
> Actually, my original problem is that, I want to create two index pattern for the same data. I have two separate timestamps in my data and I want to visualize my data based on two different time filters. I couldn't do that. So I'm creating clone of the data and then using a second time filter field on the cloned data.

You should instead may be solve that problem.

I'd recommend using an alias like:

```auto
PUT /index1/_alias/index2

```

And then you can hopefully create 2 Index Patterns in Kibana:

- One on index `index1` using the first timestamp field
- One on alias `index2` using the second timestamp field

No need to copy indices in that case.

---

<div class="post-metadata">

**Author:** ![pskhanapur](https://avatars.discourse-cdn.com/v4/letter/p/dfb087/32.png) [@pskhanapur](https://discuss.elastic.co/u/pskhanapur)\
**Post date:** [December 11, 2020, 10:07am UTC](https://discuss.elastic.co/t/automatic-copying-of-document/257687/5 "2020-12-11T10:07:14Z")

</div>

Thanks a lot David, "alias" is exactly what solves my problem

---

<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:** [January 8, 2021, 10:07am UTC](https://discuss.elastic.co/t/automatic-copying-of-document/257687/6 "2021-01-08T10:07:22Z")

</div>

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