Manager document ID in multi process and Elasticsearch


(Khánh Nguyễn) #1

Hi all. I am a newbie in Elasticsearch. I am using Elasticsearch for my system and I want to self define document ids. Each document, I generate a ID like [yearmonthday_sequence] (example 20170109_0001) and increase it for new document.
But my system is mutil process so I confused in manage ID. My approach is search all document in current day and get maximun id and increase when genarate document id but I think it's not reasonable. Do you any solution for manage id for my problem?
Thank you very much.


(David Pilato) #2

You can run an _update on a "counter" document and get back the document to get the value of the counter.

Like https://www.elastic.co/guide/en/elasticsearch/guide/current/partial-updates.html#_updating_a_document_that_may_not_yet_exist

But TBH I'm not a big fan of this. Might work if the number of documents is reasonable but if you are thinking of indexing lot of docs per second this won't work well.

My 2 cents


(system) #3

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