How to get the UUID of a document?

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:

{"_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)))

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?

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.)

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