def index(self, doc_type, sources, **kwargs):
try:<EOL><INDENT>actions = []<EOL>for source in sources:<EOL><INDENT>self._check_mappings(doc_type, source)<EOL>id_ = source['<STR_LIT:id>'] if '<STR_LIT:id>' in source else None<EOL>log.debug("<STR_LIT>", doc_type, id_)<EOL>action = {<EOL>"<STR_LIT>": self.index_name,<EOL>"<STR_LIT>": doc_type,<EOL>"<STR_LIT>": id_,<EOL>"<STR_LIT>": source<EOL>}<EOL>actions.append(action)<EOL><DEDENT>_, indexing_errors = bulk(<EOL>self._es,<EOL>actions,<EOL>**kwargs<EOL>)<EOL>if indexing_errors:<EOL><INDENT>ElasticSearchEngine.log_indexing_error(indexing_errors)<EOL><DEDENT><DEDENT>except Exception as ex:<EOL><INDENT>log.exception("<STR_LIT>", str(ex))<EOL>raise<EOL><DEDENT>
Implements call to add documents to the ES index
Note the call to _check_mappings which will setup fields with the desired mappings