Michael Pickard wrote:
Can anyone help me with the formation of a BooleanQuery ?

I want a query of the form:

x AND ( a OR b OR c OR d)

You're going to need 2 BooleanQuery objects, one for the OR'd expression in parentheses, and another for the AND and expression. Something like this:

BooleanQuery bq_or = new BooleanQuery();
bq_or.add(new TermQuery(new Term("f", "a")), false, false);
bq_or.add(new TermQuery(new Term("f", "b")), false, false);
bq_or.add(new TermQuery(new Term("f", "c")), false, false);
bq_or.add(new TermQuery(new Term("f", "d")), false, false);
BooleanQuery bq_and = new BooleanQuery();
bq_and.add(bq_or, true, false);
bq_and.add(new TermQuery(new Term("f", "x")), true, false);
...
search(bq_and, ...);

Good luck!

--MDC

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to