lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pasha Bizhan" <lucene-l...@lucenedotnet.com>
Subject RE: Boolean Query
Date Wed, 28 Dec 2005 17:10:44 GMT
Hi, 

> From: Steven Pannell [mailto:steven.pannell@zooplus.com] 

> I want to create a boolean query like:
> 
> 'book' AND ( 'fred' OR 'ginger')
>
> 
>         TermQuery t1 = new TermQuery(new Term("type","book"));
>         TermQuery t2 = new TermQuery(new Term("author","fred"));
>         TermQuery t3 = new TermQuery(new Term("title","ginger"));
> 
>         BooleanQuery q1 = new BooleanQuery();
>         q1.add(t3,false,false);
>         q1.add(t2,false,false);

Q1 is (t2 OR t3) now.

BooleanQuery q2 = new BooleanQuery();
q2.add(t1,true,false);
q2.add(q1,true,false);

Q2 is (t1 AND Q1).

I guess.

Pasha Bizhan


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