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

Reply via email to