public function indexAction() { $queryBuilder = new Application_Util_QueryBuilder($this->getLogger(), true); // support backward compatibility: interpret missing parameter searchtype as latest search if (is_null($this->getRequest()->getParam('searchtype', null))) { $this->getRequest()->setParam('searchtype', Application_Util_Searchtypes::LATEST_SEARCH); } $params = array(); try { $params = $queryBuilder->createQueryBuilderInputFromRequest($this->getRequest()); } catch (Application_Util_QueryBuilderException $e) { $this->getLogger()->err(__METHOD__ . ' : ' . $e->getMessage()); throw new Application_Exception($e->getMessage()); } // overwrite parameters in rss context // rss feeds have a fixed maximum number of items $params['rows'] = self::NUM_OF_ITEMS_PER_FEED; $params['start'] = 0; // rss feeds have both a fixed sort field and sort order $params['sortField'] = self::RSS_SORT_FIELD; $params['sortOrder'] = self::RSS_SORT_ORDER; $resultList = array(); try { $searcher = new Opus_SolrSearch_Searcher(); $resultList = $searcher->search($queryBuilder->createSearchQuery($params)); } catch (Opus_SolrSearch_Exception $exception) { $this->handleSolrError($exception); } $this->loadStyleSheet($this->view->getScriptPath('') . 'stylesheets' . DIRECTORY_SEPARATOR . 'rss2_0.xslt'); $this->setLink(); $this->setDates($resultList); $this->setItems($resultList); $this->setFrontdoorBaseUrl(); }
/** * Builds query for Solr search. * @return Opus_SolrSearch_Query|void * @throws Application_Exception, Application_Util_BrowsingParamsException, Application_Util_QueryBuilderException */ public static function getQueryUrl($request, $logger) { $queryBuilder = new Application_Util_QueryBuilder($logger); $queryBuilderInput = $queryBuilder->createQueryBuilderInputFromRequest($request); if (is_null($request->getParam('sortfield')) && ($request->getParam('browsing') === 'true' || $request->getParam('searchtype') === 'collection')) { $queryBuilderInput['sortField'] = 'server_date_published'; } if ($request->getParam('searchtype') === Application_Util_Searchtypes::LATEST_SEARCH) { return $queryBuilder->createSearchQuery(self::validateInput($queryBuilderInput, $logger, 10, 100)); } return $queryBuilder->createSearchQuery(self::validateInput($queryBuilderInput, $logger)); }
/** * Test für OPUSVIER-2708. */ public function testGetRowsFromConfig() { $config = Zend_Registry::get('Zend_Config'); $oldParamRows = $config->searchengine->solr->numberOfDefaultSearchResults; $config->searchengine->solr->numberOfDefaultSearchResults = 1337; $request = $this->getRequest(); $request->setParams(array('searchtype' => 'all')); $queryBuilder = new Application_Util_QueryBuilder(Zend_Registry::get('Zend_Log')); $result = $queryBuilder->createQueryBuilderInputFromRequest($request); //clean-up $config->searchengine->solr->numberOfDefaultSearchResults = $oldParamRows; $this->assertEquals($result['rows'], 1337); }
/** * Sets up the xml query. */ private function buildQuery($request) { $queryBuilder = new Application_Util_QueryBuilder($this->getLogger(), true); $queryBuilderInput = array(); try { $queryBuilderInput = $queryBuilder->createQueryBuilderInputFromRequest($request); } catch (Application_Util_QueryBuilderException $e) { $this->getLogger()->err(__METHOD__ . ' : ' . $e->getMessage()); throw new Application_Exception($e->getMessage()); } return $queryBuilder->createSearchQuery($queryBuilderInput); }