Get elastic shards failure upon search query across multiple indices (while creating indices)

I'm using Elastic 7.13.1. I create indices dynamically using a template based on the year of a timestamp field. So when I try to index a document with a timestamp for 2023-01-01 into index index-2023 the index will be created via the template if missing. I create the index with 5 shards and default number of replicas.

I also query multiple indices at once using the wildcard index-*. I use Go and the github.com/olivere/elastic/v7 (v7.0.32) client library.

I am running a test with a clean elastic setup (no indices created) that run a go routine to index one document per year (up to N years) and one go routine that searches for some documents (using the wildcard indices). I parse the result for shard failures and often get failures like:

[{"index":"index-2023","reason":{"index":"index-2023","index_uuid":"HQU0FmsvSDuar08SUD9lwg","reason":"[d35c437ed6dc][192.168.10.11:9300][indices:data/read/search[phase/query]]","shard":"0","type":"no_shard_available_action_exception"}},{"shard":4,"index":"index-2023","reason":{"index":"index-2023","index_uuid":"HQU0FmsvSDuar08SUD9lwg","reason":null,"shard":"4","type":"no_shard_available_action_exception"}}]

Suggesting to me that while searching the wildcard indices the new index is created by the template but not "yet" fully available. If my assumption is correct, is there a way to prevent such shard failure (e.g. wait that all shards are available before letting the newly created index available for searches)?

Is there something similiar to the wait_for_active_shards query parameter when using the create index API, but for index templates?

I was suggested to refresh the index after indexing into it and it works, or to create the indices beforehand, but I was wondering if there is any other way to "wait" the shards to be available.

Thank you!