/** * 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()); } }