Hi, Thanks for both of you for the answer.
I will try the solution of Uwe, it looks like your suggestion will solve my problem. Many thanks, Liat On 12 September 2010 16:51, Uwe Schindler <u...@thetaphi.de> wrote: > Hi, > > I always recommend my customers to not mix should and must in the same > BooleanQuery if strict boolean matching is needed. It will match all docs, > containing the MUST clause and "boost" all SHOULD terms. > > If you have some MUST terms, but you also want to have at least one of a > list of other terms (like 5 SHOULD clauses), the trick is to separate both: > Create a BooleanQuery with 2 MUST clauses, one is your required TermQuery > and the second clause is itself a BooleanQuery with all the SHOULD clauses. > This ensures that at least one of the SHOULD terms is needed together with > the MUST term. > > Uwe > > ----- > Uwe Schindler > H.-H.-Meier-Allee 63, D-28213 Bremen > http://www.thetaphi.de > eMail: u...@thetaphi.de > > > > -----Original Message----- > > From: liat oren [mailto:oren.l...@gmail.com] > > Sent: Sunday, September 12, 2010 2:04 PM > > To: java-user@lucene.apache.org > > Subject: Unexpected Results - using should and must in boolean query > > > > Hi, > > > > I am running a query and get some unexpected results. > > > > When I run boolean query on a text field for the word X, using occur = > SHOULD, > > the results contain the word X. > > > > However, when I add another boolean query on another field (country) for > the > > word Y, using occur = MUST, in the results I get only documents in > country > Y, > > but from some reason, not only that I get documents that don't contain > the > > word X, they get higher score than those contain the word X. > > > > If I change the occur of the word X in the query to MUST, it of course > fixes it, > > but I don't understand why the SHOULD "lost" its "power" when I added the > > MUST on another field. > > > > Could something like this can happen? > > How can it be solved? > > > > Many thanks, > > Liat > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-user-h...@lucene.apache.org > >