moved some logic from mapping_index to mapping_document
part of #92