'Return Result objects for any split-modulestore backend course that has
cert_name_short or cert_name_long set.'

def _split_results(self):

    split_modulestore = modulestore()._get_modulestore_by_type(ModuleStoreEnum.Type.split)
    active_version_collection = split_modulestore.db_connection.course_index
    structure_collection = split_modulestore.db_connection.structures
    branches = active_version_collection.aggregate([{'$group': {'_id': 1, 'draft': {'$push': '$versions.draft-branch'}, 'published': {'$push': '$versions.published-branch'}}}, {'$project': {'_id': 1, 'branches': {'$setUnion': ['$draft', '$published']}}}])['result'][0]['branches']
    structures = list(structure_collection.find({'_id': {'$in': branches}, 'blocks': {'$elemMatch': {'$and': [{'block_type': 'course'}, {'$or': [{'fields.cert_name_long': {'$exists': True}}, {'fields.cert_name_short': {'$exists': True}}]}]}}}, {'_id': True, 'blocks.fields.cert_name_long': True, 'blocks.fields.cert_name_short': True}))
    structure_map = {struct['_id']: struct for struct in structures}
    structure_ids = [struct['_id'] for struct in structures]
    split_mongo_courses = list(active_version_collection.find({'$or': [{'versions.draft-branch': {'$in': structure_ids}}, {'versions.published': {'$in': structure_ids}}]}, {'org': True, 'course': True, 'run': True, 'versions': True}))
    for course in split_mongo_courses:
        draft = course['versions'].get('draft-branch')
        if (draft in structure_map):
            draft_fields = structure_map[draft]['blocks'][0].get('fields', {})
        else:
            draft_fields = {}
        published = course['versions'].get('published')
        if (published in structure_map):
            published_fields = structure_map[published]['blocks'][0].get('fields', {})
        else:
            published_fields = {}
        for fields in (draft_fields, published_fields):
            for field in ('cert_name_short', 'cert_name_long'):
                if (field in fields):
                    course[field] = fields[field]
    return [Result(split_modulestore.make_course_key(course['org'], course['course'], course['run']), course.get('cert_name_short'), course.get('cert_name_long'), True) for course in split_mongo_courses]
