'Clean all documents from the index that have a specific course provided'

def _clean_course_id(self):

    if self.course_id:
        response = self.searcher.search(field_dictionary={'course': self.course_id})
        while (response['total'] > 0):
            for item in response['results']:
                self.searcher.remove(CoursewareSearchIndexer.DOCUMENT_TYPE, item['data']['id'])
            response = self.searcher.search(field_dictionary={'course': self.course_id})
    self.course_id = None
