Every document insertion generates a new doc id (doc.id()). It just bumps by one for each entry. But that ID changes upon re-indexing, and if you submit the same doc twice, it gets indexed twice and have to documents in your index that are indistinguishable except for Lucene's ID.
Otherwise, you have to make your own if what you want is a unique key associated with a particular document. It sounds like you already have a unique key, and will have to check for it before adding a document. There is no equivalent that I know of to a DBs UNIQUE_KEY constraint on a table. Best Erick