/**
  * Remove page from the index.
  * @param string $url
  */
 public function delete($url)
 {
     $query = new Term(new IndexTerm($url, 'url'));
     $hits = $this->luceneIndex->find($query);
     foreach ($hits as $hit) {
         $this->luceneIndex->delete($hit);
     }
 }
 /**
  * Delete document from the index.
  * @param string $text
  * @param string|null $field
  */
 public function delete($text, $field = null)
 {
     $query = new Term(new IndexTerm($text, $field));
     $hits = $this->luceneIndex->find($query);
     foreach ($hits as $hit) {
         $this->luceneIndex->delete($hit);
     }
 }
 /**
  * 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;
 }
 /**
  * Remove the existing entry for the given Document from the index, if it exists.
  *
  * @param Lucene\Index $index The Zend Lucene Index
  * @param string $hash
  */
 private function removeExisting(Lucene\Index $index, $hash)
 {
     try {
         $hits = $index->find(self::HASH_FIELDNAME . ':' . $hash);
         foreach ($hits as $hit) {
             $index->delete($hit->id);
         }
     } catch (\Exception $ex) {
         // FIXME no result ???
     }
 }