lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From testn <>
Subject Re: Do AND + OR Search in Lucene
Date Thu, 02 Aug 2007 10:59:24 GMT

You can create two queries from two query parser, one with AND and the other
one with OR. After you create both of them, you call setBoost() to give
different boost level and then join them together using BooleanQuery with
option BooleanClause.Occur.SHOULD. That should do the trick.

askarzaidi wrote:
> Hey Guys,
> Quick question:
> I do this in my code for searching:
> queryParser.setDefaultOperator(QueryParser.Operator.AND);
> Lucene is OR by default so I change it to AND for my requirements. Now, I
> have a requirement to do OR as well. I mean while doing AND I'd like to
> include results from OR too ... but they'll be much lower ranked than the
> AND results.
> Is there a way to do this ?
> thanks,
> AZ

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

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

View raw message