Is it possible to use a negative query in lucene?

I want to punish some terms in the query, and not ignore them at all, so the “MUST NOT” statement will not work? Is it possible to use a negative query with SHOULD in a boolean query in lucene, how does it work?

+8
indexing lucene full-text-indexing
source share
1 answer

Yes, the query query expression 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, which discusses the negative boost .

In general, this is similar to NOT, but less strict, since the relevant documents will still appear in the search results ie

Any positive rating (> 0) will affect the increase in the default rating.

Any negative result (<0) will affect the decrease in the default score.

+7
source share

Source: https://habr.com/ru/post/649986/


All Articles