/** * Create Zend Lucene index */ public function index() { foreach ($this->models as $key => $value) { $dataProvider = new ActiveDataProvider($value['dataProviderOptions']); $iterator = new DataProviderIterator($dataProvider); if (isset($value['attributes']['lang'])) { $hits = $this->luceneIndex->find('lang:' . $value['attributes']['lang']); foreach ($hits as $hit) { $this->luceneIndex->delete($hit->id); } } foreach ($iterator as $model) { $document = $this->createDocument($model, $value['attributes']); $this->luceneIndex->addDocument($document); } } $this->luceneIndex->optimize(); $this->luceneIndex->commit(); return true; }
public function __destruct() { $this->luceneIndex->commit(); }