indexingfull-text-indexinglucene

is it possible to use negative query boost in lucene?


I want to penalize some terms in query, not to ignore them at all so "MUST NOT" operator will not work? Is it possible to use negative query boost with SHOULD in boolean query in lucene, how does it work?


Solution

  • Yes, a query term boost is simply a multiplication factor, so setting it to a negative value will have the affect you want.

    Here's a thread from the lucene mailing list discussing negative boost.

    In summary in is like a NOT but less strict, in that matching documents will still appear in search results i.e.

    Any positive score (>0) will have the affect of increasing the default score.

    Any negative score (<0) will have the affect of decreasing the default score.