lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mark harwood <>
Subject Re: TermsFilter and MUST
Date Fri, 12 Sep 2008 14:03:04 GMT
TermsFilter has taken the relatively easy option of ORing terms and this is inexpensive to

Adding more complex features (mixes of MUST/SHOULD/NOT clauses) starts to require the sorts
of optimisations you see in BooleanQuery (MUST clauses accelerating processing of other clauses
through use of skipTo).
For this reason I would not want to reproduce that logic and instead suggest you use some
of the existing classes to acheive what you are after i.e something like this 
        BooleanQuery bq=new BooleanQuery();
        bq.add(new BooleanClause(new TermQuery(new Term("gender","female")),BooleanClause.Occur.MUST));
        bq.add(new BooleanClause(new TermQuery(new Term("hair","blond")),BooleanClause.Occur.MUST));
        QueryWrapperFilter qf = new QueryWrapperFilter(bq);

There is a BooleanFilter that looks from the outside to have the same semantics as BooleanQuery
(shoulds/musts etc) but this is reliant on calling each clause independently in turn to produce
a Bitset (or DocIdSet in future) then combining them. This has none of the "skipTo" optimisations
in BooleanQuery's parallel streaming of clause output.


----- Original Message ----
From: Konstantyn Smirnov <>
Sent: Friday, 12 September, 2008 11:18:17
Subject: TermsFilter and MUST

Hi gents,

is it possible to use TermsFilter with the 'MUST' occurence rule, instead of
the 'SHOULD'?

In the code:

def tf = new TermsFilter()
for( some terms ){
  tf.addTerm( new Term( .... ) )

I want that all terms MUST limit the hit list.

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

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


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

View raw message