lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <e...@ehatchersolutions.com>
Subject Re: [subscriptions] Please make org.apache.lucene.index.IndexWriter non-final
Date Sun, 05 Oct 2003 18:42:19 GMT
On Sunday, October 5, 2003, at 10:02  AM, Mike Hogan wrote:
> 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: lucene-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-dev-help@jakarta.apache.org


Mime
View raw message