Example #1
0
 /**
  * Support method for performAndProcessSearch -- perform a search based on the
  * parameters passed to the object.
  *
  * @return void
  */
 protected function performSearch()
 {
     // The "relevance" sort option is a VuFind reserved word; we need to make
     // this null in order to achieve the desired effect with Summon:
     $sort = $this->getParams()->getSort();
     $finalSort = $sort == 'relevance' ? null : $sort;
     // Perform the actual search
     $summon = $this->getSummonConnection();
     $query = new SummonQuery($summon->buildQuery($this->getParams()->getSearchTerms()), array('sort' => $finalSort, 'pageNumber' => $this->getParams()->getPage(), 'pageSize' => $this->getParams()->getLimit(), 'didYouMean' => $this->getOptions()->spellcheckEnabled()));
     if ($this->getOptions()->highlightEnabled()) {
         $query->setHighlight(true);
         $query->setHighlightStart('{{{{START_HILITE}}}}');
         $query->setHighlightEnd('{{{{END_HILITE}}}}');
     }
     $query->initFacets($this->getParams()->getFullFacetSettings());
     $query->initFilters($this->getParams()->getFilterList());
     $this->rawResponse = $summon->query($query);
     // Add fake date facets if flagged earlier; this is necessary in order
     // to display the date range facet control in the interface.
     $dateFacets = $this->getParams()->getDateFacetSettings();
     if (!empty($dateFacets)) {
         if (!isset($this->rawResponse['facetFields'])) {
             $this->rawResponse['facetFields'] = array();
         }
         foreach ($dateFacets as $dateFacet) {
             $this->rawResponse['facetFields'][] = array('fieldName' => 'PublicationDate', 'displayName' => 'PublicationDate', 'counts' => array());
         }
     }
     // Save spelling details if they exist.
     if ($this->getOptions()->spellcheckEnabled()) {
         $this->processSpelling();
     }
     // Store relevant details from the search results:
     $this->resultTotal = $this->rawResponse['recordCount'];
     // Construct record drivers for all the items in the response:
     $this->results = array();
     foreach ($this->rawResponse['documents'] as $current) {
         $this->results[] = $this->initRecordDriver($current);
     }
 }