lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mark harwood <markharw...@yahoo.co.uk>
Subject Re: TermsFilter and MUST
Date Fri, 12 Sep 2008 15:09:55 GMT
>>here I'm AND-ing each bitset. Does it look ok?

In principle it looks like it will work fine but the BooleanQuery approach I described may
prove to be faster on large datasets because ultimately td.skipTo() will be called to avoid
excessive disk reads.

Cheers
Mark



----- Original Message ----
From: Konstantyn Smirnov <injecteer@yahoo.com>
To: java-user@lucene.apache.org
Sent: Friday, 12 September, 2008 15:32:29
Subject: Re: TermsFilter and MUST


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


      

---------------------------------------------------------------------
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