@gensim.utils.synchronous('<STR_LIT>')<EOL><INDENT>def index(self, corpus=None, clear_buffer=True):<DEDENT>
if not self.model:<EOL><INDENT>msg = '<STR_LIT>' % self.basename<EOL>logger.error(msg)<EOL>raise AttributeError(msg)<EOL><DEDENT>if corpus is not None:<EOL><INDENT>self.flush(clear_buffer=True)<EOL>self.buffer(corpus)<EOL><DEDENT>if not self.fresh_docs:<EOL><INDENT>msg = "<STR_LIT>" % self<EOL>logger.error(msg)<EOL>raise ValueError(msg)<EOL><DEDENT>if not self.fresh_index:<EOL><INDENT>logger.info("<STR_LIT>" % self)<EOL>self.fresh_index = SimIndex(self.location('<STR_LIT>'), self.model.num_features)<EOL><DEDENT>self.fresh_index.index_documents(self.fresh_docs, self.model)<EOL>if self.opt_index is not None:<EOL><INDENT>self.opt_index.delete(list(self.fresh_docs.keys()))<EOL><DEDENT>logger.info("<STR_LIT>")<EOL>for docid in self.fresh_docs:<EOL><INDENT>payload = self.fresh_docs[docid].get('<STR_LIT>', None)<EOL>if payload is None:<EOL><INDENT>break<EOL><DEDENT>self.payload[docid] = payload<EOL><DEDENT>self.flush(save_index=True, clear_buffer=clear_buffer)<EOL>
Permanently index all documents previously added via `buffer`, or
directly index documents from `corpus`, if specified.

The indexing model must already exist (see `train`) before this function
is called.