コード例 #1
0
 /**
  * Lazy-loads config with values set from controller. Allows us to test config API.
  * @return Wikia\Search\Config
  */
 public function getConfig()
 {
     if ($this->config === null) {
         $this->config = new Wikia\Search\Config();
         $this->config->setLimit($this->getLimit())->setStart($this->getStart())->setNamespaces([NS_FILE])->setRank($this->getRank());
         $this->config->setFilterQueryByCode(Wikia\Search\Config::FILTER_VIDEO);
         if ($this->getSearchType() == 'premium') {
             $this->config->setWikiId(Wikia\Search\QueryService\Select\Dismax\Video::VIDEO_WIKI_ID);
         }
     }
     return $this->config;
 }
コード例 #2
0
 /**
  * Lazy-loads Wikia\Search\Config
  * @return Wikia\Search\Config
  */
 protected function getConfig()
 {
     if ($this->config === null) {
         $config = new Wikia\Search\Config();
         $config->setLimit(1);
         if ($this->getCrossWiki()) {
             $config->setCrossWikiLuceneQuery(true);
         } else {
             $config->setDirectLuceneQuery(true);
         }
         $this->config = $config;
     }
     return $this->config;
 }
コード例 #3
0
 /**
  * Search videos by topics
  * @requestParam string defaultTopic - Text to use for the topic if no topics are found on this wiki.
  * @requestParam int limit - Limit the number of results returned
  */
 public function searchVideosByTopics()
 {
     $limit = $this->getVal('limit');
     $defaultTopic = $this->getVal('defaultTopic');
     $topics = $this->getTopicsAsQuery($defaultTopic);
     if (!empty($topics)) {
         $searchConfig = new Wikia\Search\Config();
         $mm = $this->getVal('mm', '80%');
         $searchConfig->setVideoContentSearch(true)->setQuery($topics)->setMinimumMatch($mm);
         if (!empty($limit)) {
             $searchConfig->setLimit($limit);
         }
         $queryService = $this->queryServiceFactory->getFromConfig($searchConfig);
         $minDuration = $this->getVal('minseconds');
         $maxDuration = $this->getVal('maxseconds');
         if ($minDuration && $maxDuration) {
             $queryService->setMinDuration($minDuration)->setMaxDuration($maxDuration);
         }
         $log = WikiaLogger::instance();
         $log->info(__METHOD__ . ' - Querying SOLR', ['method' => __METHOD__, 'topics' => $topics, 'limit' => $limit, 'mm' => $mm, 'minDuration' => $minDuration, 'maxDuration' => $maxDuration]);
         $this->getResponse()->setFormat('json');
         $this->getResponse()->setData($queryService->searchAsApi());
     }
 }