@gensim.utils.synchronous('<STR_LIT>')<EOL><INDENT>def optimize(self):<DEDENT>
if self.fresh_index is None:<EOL><INDENT>logger.warning("<STR_LIT>")<EOL>return <EOL><DEDENT>if self.opt_index is None:<EOL><INDENT>logger.info("<STR_LIT>" % self)<EOL>self.opt_index = SimIndex(self.location('<STR_LIT>'), self.model.num_features)<EOL><DEDENT>self.opt_index.merge(self.fresh_index)<EOL>self.fresh_index.terminate() <EOL>self.fresh_index = None<EOL>self.flush(save_index=True)<EOL>
Precompute top similarities for all indexed documents. This speeds up
`find_similar` queries by id (but not queries by fulltext).

Internally, documents are moved from a fresh index (=no precomputed similarities)
to an optimized index (precomputed similarities). Similarity queries always
query both indexes, so this split is transparent to clients.

If you add documents later via `index`, they go to the fresh index again.
To precompute top similarities for these new documents too, simply call
`optimize` again.