lucene-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug Cutting <cutt...@apache.org>
Subject Re: Performance problem
Date Wed, 24 Aug 2005 19:59:19 GMT
WolfgangTäger wrote:
> While the search is carried out in a reasonably short time (about 
> 500..800ms) we have a performance problem with actually retrieving the 
> documents by code like:
> 
> for (int i = nrhits-1; i >=0; i--){
>         Document hitDoc = hits.doc(i);
>         String code=hitDoc.get("code");
>         ... statistics
> }

If you have enough RAM, a FieldCache would make this very fast.

TopDocs hits = searcher.search(query, (Filter)null, 2000);
String[] codes = FieldCache.DEFAULT.getStrings(indexReader, "code");
for (int i = 0; i < hits.scoreDocs.length; i++) {
   String code = codes[hits.scoreDocs[i].doc];
   ...
}

Doug

Mime
View raw message