/** * @param $data * @param SearchIndexInterface $index * * @return IndexInterface */ public function unindex($data, SearchIndexInterface $index) { $hits = $index->find('group_id:' . $data->id); foreach ($hits as $hit) { $index->delete($hit->id); } return $this; }
/** * removes a file from the lucene index * * @param int $fileId file id to remove from the index * * @return int count of deleted documents in the index */ public function deleteFile($fileId) { $hits = $this->index->find('fileId:' . $fileId); $this->logger->debug('found ' . count($hits) . ' hits for file id ' . $fileId); foreach ($hits as $hit) { $this->logger->debug('removing ' . $hit->id . ':' . $hit->path . ' from index'); $this->index->delete($hit); } return count($hits); }
/** * Delete index for the current exam entity * * @param \ZendSearch\Lucene\SearchIndexInterface $indexer */ public function deleteIndex($indexer) { $hits = $indexer->find('pk:' . $this->getId()); // there should be only one, but just in case foreach ($hits as $hit) { $indexer->delete($hit); } $indexer->commit(); }