Example #1
0
 /**
  * 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();
 }
Example #2
0
 private function createSeriesSearchQuery($input)
 {
     $this->logger->debug("Constructing query for series search.");
     $query = new Opus_SolrSearch_Query(Opus_SolrSearch_Query::SIMPLE);
     $query->setStart($input['start']);
     $query->setRows($input['rows']);
     if ($input['sortField'] === 'seriesnumber' || $input['sortField'] === Opus_SolrSearch_Query::DEFAULT_SORTFIELD) {
         $query->setSortField('doc_sort_order_for_seriesid_' . $input['seriesId']);
     } else {
         $query->setSortField($input['sortField']);
     }
     $query->setSortOrder($input['sortOrder']);
     $query->setCatchAll('*:*');
     $query->addFilterQuery('series_ids', $input['seriesId']);
     $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;
 }
Example #4
0
 /**
  * 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++;
             }
         }
     }
 }