# Using prefix in must\_not

**URL:** https://discuss.elastic.co/t/using-prefix-in-must-not/337480
**Category:** Elasticsearch
**Created:** [July 3, 2023, 3:26pm UTC](https://discuss.elastic.co/t/using-prefix-in-must-not/337480 "2023-07-03T15:26:17Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![breiter](https://avatars.discourse-cdn.com/v4/letter/b/94ad74/32.png) [@breiter](https://discuss.elastic.co/u/breiter)
#### Post date: [July 3, 2023, 3:26pm UTC](https://discuss.elastic.co/t/using-prefix-in-must-not/337480/1 "2023-07-03T15:26:17Z")

</div>

I am currently trying to query my data and exclude everything that begins with "EP". Am I able to use both prefix and must\_not to satisfy this? If not, what can I use?

---

<div class="post-metadata">

### Author: ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)
#### Post date: [July 3, 2023, 3:37pm UTC](https://discuss.elastic.co/t/using-prefix-in-must-not/337480/2 "2023-07-03T15:37:15Z")

</div>

Hi @breiter,

Welcome to the community! The `prefix` query should be valid within a `must_not` context. Are you seeing a particular issue with a query using both of these?

---

<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 31, 2023, 3:38pm UTC](https://discuss.elastic.co/t/using-prefix-in-must-not/337480/3 "2023-07-31T15:38:15Z")

</div>

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