lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantyn Smirnov <inject...@yahoo.com>
Subject Re: TermsFilter and MUST
Date Fri, 12 Sep 2008 14:32:29 GMT

Hi Mark,

I ended up implementing a MandatoryTermsFilter, which looks like:

class MandatoryTermsFilter extends Filter {
  
  List terms 
  
  BitSet bits( IndexReader reader ){
    int size = reader.maxDoc()
    BitSet result = new BitSet( size )
    BitSet andMask = new BitSet( size )
    andMask.set 0, size - 1, true

    terms.each{ term ->
      result.clear()
      TermDocs td = reader.termDocs( term )
      while( td.next() ){ result.set td.doc() }
      andMask &= result
    }
    return andMask
  }
  
}

here I'm AND-ing each bitset. Does it look ok?
-- 
View this message in context: http://www.nabble.com/TermsFilter-and-MUST-tp19453184p19457142.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