Autogenerate id of IndexRequest before sending it


I would like to have ids of indexed documents auto-generated, but also, I want to know the id before I'll send the request. The id is generated in IndexRequest.process(...) method, so it doesn't work for me. Can I safely use


and set the id manually? I ask because I see a field "autoGeneratedTimestamp" that is also being set during default id generation, and its getter has a comment that it "will return a positive value if the id was auto generated". If I generate the ID manually, it won't be true. Can I ignore it? Or maybe there is an another solution?

PS. I use Elasticsearch 6.4.0 (server and library).

Elasticsearch distinguishes between IDs it's generated itself and IDs that came from elsewhere, because there are some slight optimisations it can perform if it knows it generated the IDs itself. The autoGeneratedTimestamp field is part of those optimisations. However it is completely safe to generate your own IDs as you describe.

1 Like

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