How can I prevent the new indexing bug from creating useless pages on Google?

Also please check if we can use this solution for the time being (Read this on another community post)

{% if request.path == ‘/search’ and search.results_count == 0 %}

{% endif %}