fix for multi-segment indexes

When the index is splitted in more than one segment, the store command was not working fine for docID that didn't belong to the first segment. It has been added a check on maxDoc for each segment in the main loop, so that document(..) method is called only for the correct segment.