During a bulk index, get the instance count with the withNewSession block to ensure that the correct session is used to obtain the instance count