When you say you keep your documents ordered alphabetically, it's confusing to me. Are you saying that you pre-sort all your documents then insert them one after another so that automatically-generated internal Lucene ID maps exactly to the alphabetical ordering? That is, for any document IDs D1 and D2 and any documents C1 and C2 (where C1 and C2 are the alphabetical representations of the documents, whatever that means) if D1 < D2 then C1 < C2?
The short answer is that you can't insert a document into a Lucene index and have any control whatsoever about the assigned document ID. The assigned document ID is always greater than the maximum document ID already in your index. But it doesn't make sense to try. You have documents A, B, D that you index. They get IDs 1, 2, 3. Now you want to index document C. What sort of document ID would you expect? 2.5? Or do I completely misunderstand your problem? Would it work to just index a field for each document that contained the alphabetical representation and use that for retrieval ordering? I *think* you can use a FilteredTermEnum with a new Term("field", "") to enumerate all the terms in an index ( They are guaranteed to be in lexical order.....). Then you let lucene do your sorting... I'm a little fuzzy on how to go from there to a document, but I suspect there's a way. Hope this helps Erick