# How to get the UUID of a document?

**URL:** <https://discuss.elastic.co/t/how-to-get-the-uuid-of-a-document/317401>\
**Category:** Elasticsearch\
**Created:** [October 25, 2022, 11:21am UTC](https://discuss.elastic.co/t/how-to-get-the-uuid-of-a-document/317401 "2022-10-25T11:21:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wrobitza\_aveq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wrobitza_aveq/32/105113_2.png) [@wrobitza\_aveq](https://discuss.elastic.co/u/wrobitza_aveq)\
**Post date:** [October 25, 2022, 11:21am UTC](https://discuss.elastic.co/t/how-to-get-the-uuid-of-a-document/317401/1 "2022-10-25T11:21:13Z")

</div>

When I am indexing a document to Elasticsearch via Ruby, I am supplying a custom `_id` field, e.g. `analytics-development-foo_18`. I get the following response from ES:

```ruby
{"_index"=>"analytics-development-foo",
 "_id"=>"analytics-development-foo_18",
 "_version"=>5,
 "result"=>"created",
 "_shards"=>{"total"=>2, "successful"=>1, "failed"=>0},
 "_seq_no"=>50,
 "_primary_term"=>12}

```

Now, when I want to view that document, I head to _Discover_ in Kibana and I can find the document. When I show it in single document view, the URL changes to:

`https://kibana.analytics.localhost/app/discover#/doc/e30929a0-d4f4-11ec-9059-552fd0e9601e/analytics-development-foo?id=analytics-development-foo_18&breadcrumb=%23%2F%3F_g%3D(filters%3A!()%2CrefreshInterval%3A(pause%3A!t%2Cvalue%3A0)%2Ctime%3A(from%3A'2022-10-17T18%3A00%3A00.000Z'%2Cto%3A'2022-10-17T19%3A00%3A00.000Z'))%26_a%3D(columns%3A!(_id)%2Cfilters%3A!()%2Cindex%3Ae30929a0-d4f4-11ec-9059-552fd0e9601e%2Cinterval%3Aauto%2Cquery%3A(language%3Akuery%2Cquery%3A'')%2Csort%3A!(!('%40timestamp'%2Cdesc)))`

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/3/d/3d5c03c03a3214d993f64830519716bca96e213b.png)

So, the URL contains another ID, a UUID, starting with `e30929a0`. So, my questions are:

- What is that UUID?
- How can I get the UUID of a document when I know its `_id` only?

---

<div class="post-metadata">

**Author:** ![wrobitza\_aveq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wrobitza_aveq/32/105113_2.png) [@wrobitza\_aveq](https://discuss.elastic.co/u/wrobitza_aveq)\
**Post date:** [October 25, 2022, 11:29am UTC](https://discuss.elastic.co/t/how-to-get-the-uuid-of-a-document/317401/2 "2022-10-25T11:29:30Z")

</div>

Oh, I see now that this is actually the ID of the data view/index pattern to which this document belongs.

(Now, the bonus question would be: if I knew a document `_Id`, could I programmatically get the data view that corresponds to its index? I know there could be an unlimited number of data views that point to the same document, but just finding the first one would be ideal.)

---

<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:** [November 22, 2022, 11:29am UTC](https://discuss.elastic.co/t/how-to-get-the-uuid-of-a-document/317401/3 "2022-11-22T11:29:48Z")

</div>

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