Custom id when inserting a document in existing index

I am using Dev tools in Kibana to insert a new document in an existing index. But I can't figure out if I can set the _id field to a custom value. Is there a way to do this?
This is what I'm doing now:

POST user/_doc/1
{
  "name" : "John Doe",
  "licenseId" : "XXXXX",
   "age": 20
}

I want to somehow set the _id field too in this query.

It is explained in the documentation.

PUT /<target>/_doc/<_id>

In your request, the id is what cames after _doc/, so if you are using 1, the _id of the document will be 1.

If you want to set a custom id in a request like that you need to use PUT and set your custom _id after _doc.

PUT user/_doc/your-custom-id
{
  "name" : "John Doe",
  "licenseId" : "XXXXX",
   "age": 20
}

1 Like

Oooh I completely missed that, thank you!

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