lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erick Erickson" <>
Subject Re: Inserting a document into an index at a specified position
Date Fri, 07 Jul 2006 15:05:53 GMT
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 <

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

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

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

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message