# How to build query: Should have those values and must have something else?

**URL:** <https://discuss.elastic.co/t/how-to-build-query-should-have-those-values-and-must-have-something-else/65403>\
**Category:** Elasticsearch\
**Created:** [November 8, 2016, 8:28pm UTC](https://discuss.elastic.co/t/how-to-build-query-should-have-those-values-and-must-have-something-else/65403 "2016-11-08T20:28:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eugene\_Strokin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eugene_strokin/32/1238_2.png) [@Eugene\_Strokin](https://discuss.elastic.co/u/Eugene_Strokin)\
**Post date:** [November 8, 2016, 8:28pm UTC](https://discuss.elastic.co/t/how-to-build-query-should-have-those-values-and-must-have-something-else/65403/1 "2016-11-08T20:28:31Z")

</div>

Hello,  
it is easy to create a boolean should query. But my problem is that I need documents which contains those terms I've specified in the query and must contain something else.  
For example a document has a field "test":"a1 a2", and another document has "test":"a1 a2 a3".  
When I run my should query with terms "a1" and "a2" I'm getting both documents, which is expected. But I need to omit somehow the documents which contains only those terms (the first one in this example). And I need only the documents which contain more than those provided terms.  
Is it possible?  
Any ideas are appreciated.

Thank you,  
Eugene

---

<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:** [December 6, 2016, 8:28pm UTC](https://discuss.elastic.co/t/how-to-build-query-should-have-those-values-and-must-have-something-else/65403/2 "2016-12-06T20:28:35Z")

</div>

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