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

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?

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