Hi, my code receives a search query from the web, there are 5 different
searches that can be searched on - each index is searched with a single
IndexSearcher referenced in a map. it parses then performs the search
and return the best 10 results, with scores readjusted over the results
so that the best score returns 1.0. Am I performing the optiminal search
methods to do what I want ?
thanks Paul
IndexSearcher searcher = searchers.get(indexName);
QueryParser parser = new QueryParser(indexName, analyzer);
TopDocCollector collector = new TopDocCollector(10);
try {
searcher.search(parser.parse(query), collector);
}
catch (ParseException e) {
}
Results results = new Results();
results.totalHits = collector.getTotalHits();
TopDocs topDocs = collector.topDocs();
ScoreDoc docs[] = topDocs.scoreDocs;
float maxScore = topDocs.getMaxScore();
for (int i = 0; i < docs.length; i++) {
Result result = new Result();
result.score = docs[i].score / maxScore;
result.doc = searcher.doc(docs[i].doc);
results.results.add(result);
}
return results;
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org