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
Added a new commit to do this, since it touches more functions than just renaming types did.