lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantyn Smirnov <>
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 ) 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 query, filter, ... ).totalCount
instead of catFilter.getDocIdSet( indexReader ).cardinality()?



View this message in context:
Sent from the Lucene - Java Users mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message