# Search for something that must not contain xxx or xxx or xxx

**URL:** <https://discuss.elastic.co/t/search-for-something-that-must-not-contain-xxx-or-xxx-or-xxx/47926>\
**Category:** Elasticsearch\
**Created:** [April 20, 2016, 3:05pm UTC](https://discuss.elastic.co/t/search-for-something-that-must-not-contain-xxx-or-xxx-or-xxx/47926 "2016-04-20T15:05:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aaronhance](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@aaronhance](https://discuss.elastic.co/u/aaronhance)\
**Post date:** [April 20, 2016, 3:05pm UTC](https://discuss.elastic.co/t/search-for-something-that-must-not-contain-xxx-or-xxx-or-xxx/47926/1 "2016-04-20T15:05:14Z")

</div>

So I'll start off by explaining what I need to do. Users on my site will have an inventory of items, all possible items are stored in a database. The user can then search for "recipes", I want to be able to search for "recipes" that don't contain anything the user doesn't have. Here's the problem there could potentially be thousands of items and recipes, and it probably wouldn't be a good idea to have 1000+ must\_not's in a single query. How would I go about doing this in a way that wouldn't require one of Google's data centers ?

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [April 20, 2016, 3:22pm UTC](https://discuss.elastic.co/t/search-for-something-that-must-not-contain-xxx-or-xxx-or-xxx/47926/2 "2016-04-20T15:22:13Z")

</div>

See [Matching by array elements](https://discuss.elastic.co/t/matching-by-array-elements/39530/7) . There isn't a great solution but there are solutions.

---

<div class="post-metadata">

**Author:** ![aaronhance](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@aaronhance](https://discuss.elastic.co/u/aaronhance)\
**Post date:** [April 20, 2016, 5:11pm UTC](https://discuss.elastic.co/t/search-for-something-that-must-not-contain-xxx-or-xxx-or-xxx/47926/3 "2016-04-20T17:11:40Z")

</div>

The problem is must\_not["xxx"...(x10,000 items)] x 10,000 recipes = 100,000,000 comparisons x number of searches(multiple users, auto-complete). What kind of hardware would this require? I could make the item array integer ids of the items, but wouldn't it still be very demanding? Hmm, I could sort the least used items first to be compared, assuming that it stops on the first case that returns false, it could help performance.

---

<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, 2017, 10:57pm UTC](https://discuss.elastic.co/t/search-for-something-that-must-not-contain-xxx-or-xxx-or-xxx/47926/4 "2017-07-05T22:57:38Z")

</div>


