/**
  * 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);
     }
 }
 /**
  * Search page for the term in the index.
  *
  * @param $term
  * @param array $fields
  * @return array|\ZendSearch\Lucene\Search\QueryHit
  */
 public function search($term, $fields = [])
 {
     Wildcard::setMinPrefixLength($this->minPrefixLength);
     Lucene::setResultSetLimit($this->resultsLimit);
     $query = new MultiTerm();
     if (count($fields)) {
         foreach ($fields as $field => $value) {
             $query->addTerm(new IndexTerm($value, $field), true);
         }
     }
     $subTerm = explode(' ', $term);
     foreach ($subTerm as $value) {
         $query->addTerm(new IndexTerm($value), true);
     }
     return $this->luceneIndex->find($query);
 }
 /**
  * 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 ???
     }
 }