How to hide out of stock products in CloudSearch
CloudSearch supports hiding out of stock products via Shopify smart collections. You could also hide any collection from the search using the same method.

Let's see how we can do this.

We have a product Oxford Shirt that is out of stock, but it's shown in the search on the first position.
To hide the product, go to the Shopify admin panel → Collections and create a new collection. Choose collection type as automated, and the condition should work when the product inventory is equal to zero.

Note: when the product inventory becomes more than zero, the product would be removed from the collection and would be available in CloudSearch!
After the collection was saved, you can find your out of stock products there. Our Oxford Shirt has added to the collection automatically.
Next, go to the CloudSearch dashboard → Settings, and choose Hide collection and its products from search results.
There would be your store collection, and you can choose Out of stock ones.
Now, your collection Out of stock is hiding from the search results. CloudSearch needs a few minutes to re-index your store.

To test our hidden products, let's go to the storefront and try to find Oxford Shirt. As you can see it on the screenshot, it isn't available anymore.