lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Lea <ian....@gmail.com>
Subject Re: OR operator in lucene
Date Fri, 09 Sep 2011 11:54:56 GMT
Documents with both terms are likely to be returned first because they
are likely to score higher, but that isn't guaranteed.  Google "lucene
scoring" for details.

If you absolutely must have docs with both terms first, you could
execute 2 searches: the first with AND and the second with OR, then
dedup the hit lists.

Or if you are using QueryParser, use 2 clauses with boosting.  Something like

(foo AND bar)^4 (foo bar)

That syntax might be wrong.  See
http://lucene.apache.org/java/3_3_0/queryparsersyntax.html for
details.  The same idea will also apply if you are building your
queries up in code.


--
Ian.


On Fri, Sep 9, 2011 at 12:32 PM, dyzc2010 <zhoucheng2008@gmail.com> wrote:
> Hi,
>
>
> I am trying to use OR operator, and want to know if it returns the results comprising
of both keywords contained first and then either keyword later.
>
>
> To be more clear, if A OR B is enforced, should results with A and B are returned first?
>
>
> If not, how can I make sure that the OR operator can do the job.
>
>
> Thanks

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