Optimize the index prior to testing the mapping.

Related to pull request https://github.com/ruflin/Elastica/pull/359