title: How do I generate a unique id using Lucene?
body: <p>I am using Lucene to store (as well as index) various documents.</p>
  
  <p>Each document needs a persistent unique identifier (to be used as part of a URL).</p>
  
  <p>If I was using a SQL database, I could use an <code>integer primary key auto_increment</code> (or similar) field to automatically generate a unique id for every record that was added.</p>
  
  <p>Is there any way of doing this with Lucene?</p>
  
  <p>I am aware that documents in Lucene are numbered, but have noted that these numbers are reallocated over time.</p>
  
  <p>(I'm using the Java version of Lucene 3.0.3.)</p>