lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Rhoden <jrho...@unimelb.edu.au>
Subject Re: Hopfully simple question constructing BooleanQuery
Date Tue, 15 Dec 2009 05:30:56 GMT
Exactly what I was trying to do. Thanks.

On 15/12/2009, at 4:25 PM, TCK wrote:

> How about the following?
>
> BooleanQuery bq1 = new BooleanQuery();
> bq1.add(new PrefixQuery(new
> Term("heading",word)),BooleanClause.Occur.SHOULD);
> bq1.add(new PrefixQuery(new
> Term("attribute",word)),BooleanClause.Occur.SHOULD);
>
> BooleanQuery bq = new BooleanQuery();
> bq.add(bq1, BooleanClause.Occur.MUST);
> if(subjectId.length()>0)
>    bq.add(new PrefixQuery(new Term("subject_id",subjectId)),
> BooleanClause.Occur.MUST);
>
> I think bq should now be your desired query.
>
> -TCK


____________________________________
Information Technology Services,
The University of Melbourne

Email: jrhoden@unimelb.edu.au
Phone: +61 3 8344 2884
Mobile: +61 4 1095 7575


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