Correctness of "should not" query in "Elasticsearch queries" (lesson3) of Elastic Engineer1

Below is the session provided in lesson.

When I tried , I could see many titles with stack word, though I get 260 hits

Could you please check, whether the query given in lecture is correct?

You are correct. This query returns 260 hits on the blogs dataset. Thank you for reporting. We will update the lesson.

Not only result count; but result itself confusing me.
requirement is
"Find blogs that contain "elastic", but I prefer blogs that do not contain "stack".

And the result of the provided query contains, multiple "stack" term! Could you please help me to understand why it is so?

What you're doing here, is implement a "should not". It does not exclude documents that contain the word "stack" (as a "must not" would do), but instead it ranks those documents lower.

What you will see in your search results is that documents without the word "stack" are ranked highest. Those that do contain the word "stack" are ranked below that.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.