Query builders - should not / should not

I'm new to the search engine, and I was wondering if anyone could help me clarify the Must / MustNot and If / ShouldNot queries.


My understanding is this:

Must / MustNot requests are absolute definitions (i.e., the result should / should not contain the specified field)

Requests / Posts are not relative definitions (i.e. in some scenarios it should / should not contain the specified fields)


If this is correct, could someone please provide me an example of when you will use Should / ShouldNot ... and if my understanding is completely wrong - someone will be kind enough to explain this to me (or tell me a good one site)?

Thanks!

Ps. I use elastic search (based on Lucene), but any examples / explanations are welcome

+4
source share
1 answer

Your understanding is correct. SHOULD NOT get results at a lower weight, but SHOULD NOT turn on.

SHOULD NOT be used when the term probably refers to a different domain, but in some cases may be in the same document as the one I'm looking for. For example, Google knows that I am a Java programmer. When I ask for "ant", the first result will be "Apache Ant". I can use MUST NOT as "-Apache", or I can use SHOULD NOT "Apache" just in case any page describes the special place of ants in the Apache Aboriginal worldview.

Or, for example, I'm looking for free software to complete a task; However, I would think of a paid one if it is not expensive or they have a personal license. Therefore, I SHOULD NOT “buy now,” and the results will include paid software, but lower in the list.

+4
source

All Articles