if (ranks == null) return ("");
try
{
//*-- submit the question to the search engine and fetch the hits
Hits hits = getHits(question);
if (hits == null) throw new IOException("Could not find any hits for question " + question);
//*-- build the list of answers
DbTools dbt = Constants.getDbt();
dbt.openDB(Constants.EXT_FILES_DB, true, false); //*-- read only access
Explanation explanation;
LOOP: for (int i = 0; i < hits.length(); i++)
{
//*-- limit explanations for the top 100 hits
if (i > 100) break LOOP; boolean foundHit = false;
//*-- check if the hit rank matches the passed rank
for (int j = 0; j < ranks.length; j++) if (ranks[j] == i) foundHit = true;
if (!foundHit) continue LOOP;
retv.append("Document: " + i + Constants.NEWLINE);
explanation = is.explain(query, hits.id(i));
Document doc = hits.doc(i);
String key = doc.get("key");
DatabaseEntry data = new DatabaseEntry();
if (!dbt.fetch(key, data)) continue LOOP;
//*-- extract the text
IndexableDoc idoc = new IndexableDoc();
idoc = (IndexableDoc) idoc.getBdbBinding().entryToObject(data);
String line= idoc.getContents().toString();
if (line.length() > 1000) line = line.substring(0, 999);
retv.append(" Score: " + hits.score(i) + " TEXT: " + line + Constants.NEWLINE);
retv.append(explanation.toString());
retv.append("------------------------------------------------------------------");
retv.append(Constants.NEWLINE); retv.append(Constants.NEWLINE);
}
} //*-- end of try