/** * Returns all index documents that are associated to the given collection id. * * @param int $collectionId * @return array An array of Opus_SolrSearch_Result objects. * @throws Opus_SolrSearch_Exception */ private function getListItems($collectionId) { $query = new Opus_SolrSearch_Query(Opus_SolrSearch_Query::SIMPLE); $query->setCatchAll('*:*'); $query->addFilterQuery('collection_ids', $collectionId); $query->setRows(Opus_SolrSearch_Query::MAX_ROWS); $solrsearch = new Opus_SolrSearch_Searcher(); return $solrsearch->search($query)->getResults(); }
* @version $Id: find_missing_published_docs_in_searchindex.php 12011 2013-07-05 19:39:58Z sszott $ */ /** * * Dieses Skript gibt alle IDs der Dokumente zurück, die im Server State * published sind, aber aufgrund eines Fehlers nicht im Index repräsentiert sind. * * Siehe dazu auch die Story OPUSVIER-2368. * */ $numOfErrors = 0; $finder = new Opus_DocumentFinder(); $finder->setServerState('published'); foreach ($finder->ids() as $docId) { // check if document with id $docId is already persisted in search index $query = new Opus_SolrSearch_Query(Opus_SolrSearch_Query::DOC_ID); $query->setField('id', $docId); $query->setReturnIdsOnly(true); $query->setRows(Opus_SolrSearch_Query::MAX_ROWS); $searcher = new Opus_SolrSearch_Searcher(); if ($searcher->search($query)->getNumberOfHits() != 1) { echo "document # {$docId} is not stored in search index\n"; $numOfErrors++; } } if ($numOfErrors > 0) { echo "{$numOfErrors} missing documents were found\n"; } else { echo "no errors were found\n"; } exit;
private function createAllSearchQuery($input) { $this->logger->debug("Constructing query for all search."); $query = new Opus_SolrSearch_Query(Opus_SolrSearch_Query::ALL_DOCS); $query->setStart($input['start']); $query->setRows($input['rows']); $query->setSortField($input['sortField']); $query->setSortOrder($input['sortOrder']); $this->addFiltersToQuery($query, $input); if ($this->export) { $query->setReturnIdsOnly(true); } $this->logger->debug("Query {$query} complete"); return $query; }
private function getDocsInSearchIndex($checkConsistency = true) { $searcher = new Opus_SolrSearch_Searcher(); $query = new Opus_SolrSearch_Query(); $query->setCatchAll("*:*"); $query->setRows(Opus_SolrSearch_Query::MAX_ROWS); $resultList = $searcher->search($query, $checkConsistency); return $resultList; }
/** * Find documents in Solr index, that are not in database or that are in * datbase but not in serverState published Remove such documents from Solr * index. * */ private function checkSearchIndex() { $query = new Opus_SolrSearch_Query(); $query->setCatchAll("*:*"); $query->setRows(Opus_SolrSearch_Query::MAX_ROWS); $resultList = $this->searcher->search($query, $this->validateDocIds); $results = $resultList->getResults(); foreach ($results as $result) { $id = $result->getId(); try { $doc = new Opus_Document($id); } catch (Opus_Model_NotFoundException $e) { $this->logger->info("inconsistency found for document {$id}: document is in Solr index, but is not in database."); $this->numOfInconsistencies++; if ($this->removeDocumentFromSearchIndex($id)) { $this->numOfDeletions++; } continue; } if ($doc->getServerState() != 'published') { $this->logger->info("inconsistency found for document {$id}: document is in Solr index, but is not in ServerState published."); $this->numOfInconsistencies++; if ($this->removeDocumentFromSearchIndex($id)) { $this->numOfDeletions++; } } } }