lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Calabrese <m...@jasoncalabrese.com>
Subject Re: Inserting a document into an index at a specified position
Date Fri, 07 Jul 2006 16:10:17 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 <
> C2?

Yes, this is a pre-sort. For our application we have some fairly large result 
sets and using the standard sort on a name field was too slow.  By 
pre-sorting before we index we can make sure that all the docs are inserted 
in alpha order, and then sort them by index order just as fast or faster than 
the standard relvance sort.

This:
Hits hits = searcher.search(query, Sort.INDEXORDER);

is much faster than:
Hits hits = searcher.search(query, new Sort("fullname"));

> 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.

I know that there is no direct way to insert a doc a at a specified position 
with a single IndexWriter method, but it seems that there is a better way 
then reindexing everything.

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message