This collector uses no resources, I would recreate it inside the loop. Its just a thin class in young gen heap (like a autoboxed number). If you really want to reuse, you have to log the last count and simply measure the difference as you cannot reset.
----- Uwe Schindler H.-H.-Meier-Allee 63, D-28213 Bremen http://www.thetaphi.de eMail: u...@thetaphi.de > -----Original Message----- > From: Konstantyn Smirnov [mailto:inject...@yahoo.com] > Sent: Monday, July 25, 2011 4:16 PM > To: java-user@lucene.apache.org > Subject: RE: Reusing a CachingWrapperFilter > > > Uwe Schindler wrote: > > > > To just count the results use TotalHitCountCollector (since Lucene Core > > 3.1) > > with IndexSaercher.search(). > > > ok, thanks for that! > > so the code should look like: > > CachingWrapperFilter cwf = new CachingWrapperFilter( filter ) > > searcher.search( query, cwf ... ) // search 1st time, to populate cache > > for( cat in categories ){ > TotalHitCountCollector thcc = new TotalHitCountCollector() > searcher.search new TermQuery( new Term( 'category', cat ) ), cwf, thcc > long freq = thcc.totalHits > } > > TotalHitCountCollector doesn't calculate the score, does it? > Can I reuse the thcc instance in the loop? > > TIA > > -- > View this message in context: http://lucene.472066.n3.nabble.com/Reusing- > a-CachingWrapperFilter-tp3196928p3197593.html > Sent from the Lucene - Java Users mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-user-h...@lucene.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org