lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Quail <m...@cenqua.com>
Subject Re: Fastest way to fetch N documents with unique keys within large numbers of indexes..
Date Tue, 07 Jun 2005 03:20:28 GMT
> We have a system where I'll be given 10 or 20 unique keys.

I assume you mean you have one unique-key field, and you are given  
10-20 values to find for this one field?
>
> Internally I'm creating a new Term and then calling  
> IndexReader.termDocs() on this term.  Then if termdocs.next()  
> matches then I'll return this document.

Are you calling reader.termDocs() inside a (tight) loop? It might be  
better to create one TermEnum, and use "seek". Something like this:

reader = ...;
td = reader.termDocs();

String[] keys = ....; // your unique keys;
sort(keys); // this probably helps seek() below

for (key in keys) {
     Term t = new Term("unique", key);
     td.seek(t);
     if (td.next()) {
         // found a match
     }
}

I'm pretty sure that will work. And if you can avoid the multi- 
threading issues, you might try and use the same TermDocs object for  
as long as possible (that is, move it up out of as many tight loops  
as you can).

=Matt

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