# "Find all entries that don't contain values from an array"

**URL:** <https://discuss.elastic.co/t/find-all-entries-that-dont-contain-values-from-an-array/203500>\
**Category:** Elasticsearch\
**Created:** [October 14, 2019, 5:41pm UTC](https://discuss.elastic.co/t/find-all-entries-that-dont-contain-values-from-an-array/203500 "2019-10-14T17:41:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![BonesyWonesy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bonesywonesy/32/55870_2.png) [@BonesyWonesy](https://discuss.elastic.co/u/BonesyWonesy)\
**Post date:** [October 14, 2019, 5:41pm UTC](https://discuss.elastic.co/t/find-all-entries-that-dont-contain-values-from-an-array/203500/1 "2019-10-14T17:41:19Z")

</div>

I have a list of magazines for sale and each of them has a unique 'magazineId'.

I also have an array of ids like [123, 456, 789] representing which ids for magazines a user has already purchased.

Is there a way to query for all magazines which don't have magazineId's that are in the array?

right now I'm just doing a:  
{ "must\_not": [  
"match": { "magazineId": 123 },  
"match": { "magazineId": 456 },  
"match": { "magazineId": 789 ]  
]  
}

But I suspect when a user has purchased many magazines (1000+) the query will eventually fail. Would writing a script to see if the values exist in the array be the way to go instead?

---

<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:** [November 11, 2019, 5:41pm UTC](https://discuss.elastic.co/t/find-all-entries-that-dont-contain-values-from-an-array/203500/2 "2019-11-11T17:41:20Z")

</div>

Closed on November 11, 2019, 5:41pm UTC

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