I can add document with id which is formated like xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. but when i create new document without setting up id it will be like xx-xxxxxxxxxxxxxxxxx. how can i configure elasticsearch to create new id with the same format.
When you add a document to ES using a POST, it automatically generates the ID to be a 22-character URL-safe UUID, per the documentation. There is no internal way to generate IDs via some other template, for example, so if you need to do that, you need to add the document with a PUT and specify the ID at that time in whatever you're using to index the document
Ok but how can i generate unique uuid (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) for es to put it ?
The 8-4-4-4-12 format you mention is often associated with RFC 4122. You're probably best to look to use whatever UUID generation library/class/function is available for whatever programming language you're using to push data into ES. You can usually search for "RFC 4122 " or "UUID " on the Internet to find appropriate libraries.
Thank you. i just thought there is some sort of uuid generator in es
I want to write Elastic plugin which will check if there is an id field in indexing document and if no then it will generate id of the type i needed. HOw to do it? i can't regsiter mapper for _id field.