Example #1
0
 /**
  * Do the actual search
  * 
  * @param Query $search		search object
  * @param int $start							[optional] starting record number
  * @param int $max								[optional] max records
  * @param string $sort							[optional] sort order
  * 
  * @return Results
  */
 protected function doSearch(Search\Query $search, $start = 1, $max = 10, $sort = "")
 {
     // prepare the query
     $query = $search->toQuery();
     // facets to include in the response
     $facets_to_include = array();
     foreach ($this->config->getFacets() as $facet_config) {
         $facets_to_include[(string) $facet_config["internal"]] = (string) $facet_config["internal"] . ",or,1," . (string) $facet_config["max"];
     }
     // limits
     $facets = array();
     foreach ($search->getLimits(true) as $limit) {
         // remove chosen facet from response
         // @todo: make multi-value facets selectable
         $facets_to_include = Parser::removeFromArray($facets_to_include, $limit->field);
         array_push($facets, $limit->field . "," . str_replace(',', '\\,', $limit->value) . ",false");
     }
     // set actual response facets
     $this->summon_client->setFacetsToInclude($facets_to_include);
     // filter out formats
     foreach ($this->formats_exclude as $format) {
         array_push($facets, "ContentType,{$format},true");
     }
     // holdings only
     if ($search->isHoldingsOnly()) {
         $this->summon_client->limitToHoldings();
     }
     // summon deals in pages, not start record number
     if ($max > 0) {
         $page = ceil($start / $max);
     } else {
         $page = 1;
     }
     // get the results
     $summon_results = $this->summon_client->query($query, $facets, $page, $max, $sort);
     return $this->parseResponse($summon_results);
 }