# Get only latest version of document

**URL:** https://discuss.elastic.co/t/get-only-latest-version-of-document/186403
**Category:** Elasticsearch
**Created:** [June 19, 2019, 7:45am UTC](https://discuss.elastic.co/t/get-only-latest-version-of-document/186403 "2019-06-19T07:45:41Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![nitin.anand](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nitin.anand/32/48350_2.png) [@nitin.anand](https://discuss.elastic.co/u/nitin.anand)
#### Post date: [June 19, 2019, 7:45am UTC](https://discuss.elastic.co/t/get-only-latest-version-of-document/186403/1 "2019-06-19T07:45:41Z")

</div>

i experience an issue where the search returns all versions of a document randomly. Can this be controlled somehow, that i only get the latest version of document.

---

<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 19, 2019, 8:44am UTC](https://discuss.elastic.co/t/get-only-latest-version-of-document/186403/2 "2019-06-19T08:44:18Z")

</div>

There's no notion of document versioning that can be returned. Only the last version of a document can be accessed.

Most likely you are not using the same document id for the same document.

---

<div class="post-metadata">

### Author: ![nitin.anand](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nitin.anand/32/48350_2.png) [@nitin.anand](https://discuss.elastic.co/u/nitin.anand)
#### Post date: [June 19, 2019, 9:57am UTC](https://discuss.elastic.co/t/get-only-latest-version-of-document/186403/3 "2019-06-19T09:57:33Z")

</div>

Hi David

It sounds positivebut it seems that somewhere during indexing a document we are missing something that shows same document with different versions 1, 2, 4, 6, 9 in our search index.

I see the different versions present in index.

We are reading the data from a json file and updating documents. When i look at the index function it seems we take id as a parameter while indexing.

```
.IndexAsync(nodes, indexName, type, mappedjDocument, id);

```

Is there something particular here you can guess i should look at it for example while debugging ?

Would be great  
thanks  
Nitin

---

<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 19, 2019, 12:58pm UTC](https://discuss.elastic.co/t/get-only-latest-version-of-document/186403/4 "2019-06-19T12:58:13Z")

</div>

What is the output of the search request which shows different versions of the same document ?

---

<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 17, 2019, 12:58pm UTC](https://discuss.elastic.co/t/get-only-latest-version-of-document/186403/5 "2019-07-17T12:58:13Z")

</div>

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