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

**URL:** <https://discuss.elastic.co/t/correctness-of-should-not-query-in-elasticsearch-queries-lesson3-of-elastic-engineer1/238991>\
**Category:** Elastic Training\
**Created:** [June 28, 2020, 8:01am UTC](https://discuss.elastic.co/t/correctness-of-should-not-query-in-elasticsearch-queries-lesson3-of-elastic-engineer1/238991 "2020-06-28T08:01:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![manojb1-in.ibm.com](https://avatars.discourse-cdn.com/v4/letter/m/c68b51/32.png) [@manojb1-in.ibm.com](https://discuss.elastic.co/u/manojb1-in.ibm.com)\
**Post date:** [June 28, 2020, 8:01am UTC](https://discuss.elastic.co/t/correctness-of-should-not-query-in-elasticsearch-queries-lesson3-of-elastic-engineer1/238991/1 "2020-06-28T08:01:44Z")

</div>

Below is the session provided in lesson.

 ![Selection_320](https://us1.discourse-cdn.com/elastic/original/3X/2/6/263d4e6f1f555a6bcc5dafc595c5cd35c7c83eca.png)

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

 ![Selection_321](https://us1.discourse-cdn.com/elastic/original/3X/0/7/07121603e708aaab14f839de278ea8dfa24b9293.png)

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

---

<div class="post-metadata">

**Author:** ![abdon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdon/32/9195_2.png) [@abdon](https://discuss.elastic.co/u/abdon)\
**Post date:** [June 29, 2020, 8:18am UTC](https://discuss.elastic.co/t/correctness-of-should-not-query-in-elasticsearch-queries-lesson3-of-elastic-engineer1/238991/2 "2020-06-29T08:18:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![manojb1-in.ibm.com](https://avatars.discourse-cdn.com/v4/letter/m/c68b51/32.png) [@manojb1-in.ibm.com](https://discuss.elastic.co/u/manojb1-in.ibm.com)\
**Post date:** [June 29, 2020, 1:40pm UTC](https://discuss.elastic.co/t/correctness-of-should-not-query-in-elasticsearch-queries-lesson3-of-elastic-engineer1/238991/3 "2020-06-29T13:40:47Z")

</div>

> [@abdon](#):
>
> query returns 260 hits on the blogs dataset. Th

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?

---

<div class="post-metadata">

**Author:** ![abdon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdon/32/9195_2.png) [@abdon](https://discuss.elastic.co/u/abdon)\
**Post date:** [June 29, 2020, 2:01pm UTC](https://discuss.elastic.co/t/correctness-of-should-not-query-in-elasticsearch-queries-lesson3-of-elastic-engineer1/238991/4 "2020-06-29T14:01:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 29, 2020, 2:01pm UTC](https://discuss.elastic.co/t/correctness-of-should-not-query-in-elasticsearch-queries-lesson3-of-elastic-engineer1/238991/5 "2020-07-29T14:01:46Z")

</div>

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