Improve Elasticsearch error handling in try_to_index

* Iterate the correct number of times, instead of half the number of specified times
* If indexing fails at the end, reraise the exception instead of silently swallowing it