Moved the updateMappingOnMaster logic into a single place.

Percolate, index and bulk now use the same logic.