lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantyn Smirnov <inject...@yahoo.com>
Subject Reusing a CachingWrapperFilter
Date Mon, 25 Jul 2011 09:07:34 GMT
Hi all!

are there any limitations or implications on reusing a CWF?

In my app I'm doing the following:

Filter filter = new BooleanFilter(...) 
// initialized with a couple of Term-, Range-, Boolean- and PrefixFilter

CachingWrapperFilter cwf = new CachingWrapperFilter( filter )

searcher.search( query, cwf ... ) // << here, the filter's docIdSet gets
cached, right?

// now I need to iterate over a list of categories and calculate the number
of goods in each of them

for( cat in categories ){
  Filter catFilter = new BooleanFilter()
  TermsFilter tf = new TermsFilter()
  tf.addTerm new Term( 'category, cat )

  catFilter.add new FilterClause( cwf, ... )    
  catFilter.add new FilterClause( tf, ... )

  long freq = catFilter.getDocIdSet( indexReader ).cardinality()
 
  //do stuff with freq
}

Is this a correct use? Shall the filter with a pre-cached bitSet be combined
with the new one inside the BooleanFilter like that?
Or maybe should I use searcher.search( query, filter, ... ).totalCount
instead of catFilter.getDocIdSet( indexReader ).cardinality()?

TIA

Konstantyn

--
View this message in context: http://lucene.472066.n3.nabble.com/Reusing-a-CachingWrapperFilter-tp3196928p3196928.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message