Omiting items from shopify search results, Question

So I want to omit certain items from my search results, preferably using a tag.

Shopify guide has a section on hiding out of stock products.

Can this code be edited to use “tags” as a way to omit items.

The guide. https://shopify.dev/tutorials/customize-theme-edit-storefront-search-results

The code.

...

I’m unsure of how to change this.