I am trying to unit test this:
public int search(final String query, int beginIndex, final int
endIndex, final List collector) throws SearchService.Exception {
int numHits = 0;
try {
final Searcher searcher = new IndexSearcher(INDEX_FILE_PATH);
final Analyzer analyzer = new StandardAnalyzer();
final Query q = QueryParser.parse(query, "contents", analyzer);
final Hits hits = searcher.search(q);
numHits = hits.length();
while (beginIndex <= endIndex && beginIndex < numHits) {
final Document doc = hits.doc(beginIndex++);
collector.add(doc.get("id"));
}
Another suggestion - use the HitCollector search method rather than getting Hits back and then walking them. Hits is adding a level of indirection and caching that you obviously don't need here - and HitCollector would streamline your code a bit here.
Erik
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]