# Hide a document from the searching

**URL:** <https://discuss.elastic.co/t/hide-a-document-from-the-searching/236313>\
**Category:** Elasticsearch\
**Created:** [June 9, 2020, 10:31am UTC](https://discuss.elastic.co/t/hide-a-document-from-the-searching/236313 "2020-06-09T10:31:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gitterhh](https://avatars.discourse-cdn.com/v4/letter/g/b19c9b/32.png) [@gitterhh](https://discuss.elastic.co/u/gitterhh)\
**Post date:** [June 9, 2020, 10:31am UTC](https://discuss.elastic.co/t/hide-a-document-from-the-searching/236313/1 "2020-06-09T10:31:19Z")

</div>

We want to use Elasticsearch as primary data source, and we also want to keep track of changes of document, so we want to store all the versions of a document.

As a solution will be to hide previous document versions from the index, is this possible?

---

<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 9, 2020, 11:36am UTC](https://discuss.elastic.co/t/hide-a-document-from-the-searching/236313/2 "2020-06-09T11:36:03Z")

</div>

I'd probably index the document twice:

- One in the live index using the same `_id` always so updates will overwrite any existing document.
- One in the historical index using id+timestamp as the `_id` so all versions will be kept.

---

<div class="post-metadata">

**Author:** ![gitterhh](https://avatars.discourse-cdn.com/v4/letter/g/b19c9b/32.png) [@gitterhh](https://discuss.elastic.co/u/gitterhh)\
**Post date:** [June 9, 2020, 12:36pm UTC](https://discuss.elastic.co/t/hide-a-document-from-the-searching/236313/3 "2020-06-09T12:36:37Z")

</div>

Can you please advise why to use also timestamp in the `_id`?

---

<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 9, 2020, 12:59pm UTC](https://discuss.elastic.co/t/hide-a-document-from-the-searching/236313/4 "2020-06-09T12:59:18Z")

</div>

Better idea. Don't set any id and let elasticsearch create one for you.

---

<div class="post-metadata">

**Author:** ![gitterhh](https://avatars.discourse-cdn.com/v4/letter/g/b19c9b/32.png) [@gitterhh](https://discuss.elastic.co/u/gitterhh)\
**Post date:** [June 9, 2020, 1:03pm UTC](https://discuss.elastic.co/t/hide-a-document-from-the-searching/236313/5 "2020-06-09T13:03:41Z")

</div>

Ok, thanks.

Can you please also advise if it is possible to use a processor, or any other tool, to automatically add a new document in the historical index when a new documented is added in or updated in live index?

---

<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 7, 2020, 1:03pm UTC](https://discuss.elastic.co/t/hide-a-document-from-the-searching/236313/6 "2020-07-07T13:03:54Z")

</div>

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