# Combining must, should, and must\_not

**URL:** <https://discuss.elastic.co/t/combining-must-should-and-must-not/184781>\
**Category:** Elasticsearch\
**Created:** [June 7, 2019, 3:22pm UTC](https://discuss.elastic.co/t/combining-must-should-and-must-not/184781 "2019-06-07T15:22:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kinbaum](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kinbaum](https://discuss.elastic.co/u/Kinbaum)\
**Post date:** [June 7, 2019, 3:22pm UTC](https://discuss.elastic.co/t/combining-must-should-and-must-not/184781/1 "2019-06-07T15:22:49Z")

</div>

Hello, I am working with elasticsearch within Gentics Mesh CMS and I'm trying to construct a query that returns a series of nodes. I have two nodes tagged with keywordA. One of those nodes has tag keywordB. Based on the following query, I would expect to see one node returned, however I see two.

```
{
    "query": {
        "nested": {
            "ignore_unmapped": "true",
            "path": "tagFamilies.keywords.tags",
            "query": {
                "bool": {
                    "must": [
                        {
                            "match_phrase": {
                                "tagFamilies.keywords.tags.name": "keywordA"
                            }
                        }
                    ],
                    "must_not": [
                        {
                            "match": {
                                "tagFamilies.keywords.tags.name": "keywordB"
                            }
                        }
                    ]
                }
            }
        }
    }
}

```

Does this syntax look accurate, or am I missing something?  
Thanks in advance

---

<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 5, 2019, 3:23pm UTC](https://discuss.elastic.co/t/combining-must-should-and-must-not/184781/2 "2019-07-05T15:23:00Z")

</div>

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