public function getSearchResults($term, $totalLimit = self::SEARCH_RESULTS_LIMIT)
 {
     wfProfileIn(__METHOD__);
     $term = trim($term);
     $ret = array();
     if (!empty($this->app->wg->EnableWikiaSearchExt) && !empty($term)) {
         wfloadExtensionMessages('GameGuides');
         $cacheKey = $this->generateCacheKey(__METHOD__ . ':' . str_replace(array(' ', "\n", "\t", "\r"), '_', $term) . ":{$totalLimit}");
         $ret = $this->loadFromCache($cacheKey);
         if (empty($ret)) {
             $resultSet = $this->getResultSet($term, $totalLimit);
             $ret['textResults'] = array();
             $count = 0;
             if ($resultSet->hasResults()) {
                 $textResults = array();
                 $mwService = new Wikia\Search\MediaWikiService();
                 foreach ($resultSet as $result) {
                     try {
                         $textResults[] = array('textForm' => $result->getTitle(), 'urlForm' => $mwService->getLocalUrlForPageId($result['pageid'], array('useskin' => GameGuidesController::SKIN_NAME)));
                         $count++;
                     } catch (Exception $e) {
                     }
                     // result is probably stale/deleted
                 }
                 $ret['textResults'] = $textResults;
                 $ret['count'] = $count;
             }
         }
         $this->storeInCache($cacheKey, $ret);
     }
     wfProfileOut(__METHOD__);
     return $ret;
 }
<?php

/**
 * Lets us test the performance of a given snippetting approach
 * @package MediaWiki
 * @addtopackage maintenance
 */
ini_set("include_path", dirname(__FILE__) . "/../../../../maintenance/");
require_once "commandLine.inc";
$options = getopt('i:s::fc::', ['id:', 'service::', 'force', 'conf::']);
global $wgEnableParserCache, $wgAllowMemcacheReads;
$wgEnableParserCache = false;
$wgAllowMemcacheReads = false;
$articleId = $options['id'];
$mws = new Wikia\Search\MediaWikiService();
$service = new ArticleService($mws->getCanonicalPageIdFromPageId($articleId));
$start = microtime(true);
$type = 'default';
if (isset($options['service']) && $options['service'] == 'solr') {
    $type = 'solr';
    $response = $service->getTextSnippetFromSolr();
} else {
    $response = $service->getTextSnippet();
}
echo sprintf("%.2f (%s) %s\n", microtime(true) - $start, $type, $response);
<?php

// get wiki thumbnail and thumbnail tracking
$isOnWikiMatch = isset($result['onWikiMatch']) && $result['onWikiMatch'];
$imageFileName = PromoImage::fromPathname($result['image_s'])->ensureCityIdIsSet($result['id'])->getPathname();
$imageOriginalURL = ImagesService::getImageSrcByTitle($corporateWikiId, $imageFileName, WikiaSearchController::CROSS_WIKI_PROMO_THUMBNAIL_WIDTH, WikiaSearchController::CROSS_WIKI_PROMO_THUMBNAIL_HEIGHT);
if (!empty($imageOriginalURL)) {
    $imageURL = ImagesService::overrideThumbnailFormat($imageOriginalURL, ImagesService::EXT_JPG);
    $thumbTracking = 'class="wiki-thumb-tracking" data-pos="' . $pos . '" data-event="search_click_wiki-thumb"';
}
if (empty($imageURL)) {
    // display placeholder image if no thumbnail
    $imageURL = $wg->ExtensionsPath . '/wikia/Search/images/wiki_image_placeholder.png';
    $thumbTracking = 'class="wiki-thumb-tracking" data-pos="' . $pos . '" data-event="search_click_wiki-no-thumb"';
}
$service = new Wikia\Search\MediaWikiService();
$pagesMsg = $service->shortnumForMsg($result['articles_i'] ?: 0, 'wikiasearch2-pages');
$imgMsg = $service->shortnumForMsg($result['images_i'] ?: 0, 'wikiasearch2-images');
$videoMsg = $service->shortnumForMsg($result['videos_i'] ?: 0, 'wikiasearch2-videos');
$title = ($sn = $result->getText('sitename_txt')) ? $sn : $result->getText('headline_txt');
$url = $result->getText('url');
?>

<li class="result">
	<?php 
$suffix = $result['exactWikiMatch'] ? "match" : "wiki";
$trackingData = 'class="result-link" data-pos="' . $pos . '" data-event="search_click_' . $suffix . '"';
?>
	<a href="<?php 
echo $url;
?>
 /**
  * JSON service that supports the access of video (and optionally photo) content from both
  * the current and premium video wiki.
  *
  *  Request params:
  *  -- q (required) the query
  *  -- videoOnly (optional) whether to only include videos (false by default)
  *  -- next (optional) pagination value
  *
  */
 public function combinedMediaSearch()
 {
     $request = $this->getRequest();
     $query = $request->getVal('q');
     if (strlen($query) == 0) {
         throw new Exception("Please include a query value for parameter 'q'");
     }
     $config = new Wikia\Search\Config();
     $videoOnly = (bool) $request->getVal('videoOnly', false);
     $config->setQuery($query)->setCombinedMediaSearch(true)->setCombinedMediaSearchIsVideoOnly($videoOnly)->setLimit(4)->setStart($this->getVal('next', 0));
     $results = $this->queryServiceFactory->getFromConfig($config)->searchAsApi(['url', 'id', 'pageid', 'wid', 'title'], true);
     $dimensions = ['width' => 120, 'height' => 90];
     $service = new \Wikia\Search\MediaWikiService();
     foreach ($results['items'] as &$result) {
         if (!isset($result['thumbnail'])) {
             $result['thumbnail'] = $service->getThumbnailHtmlFromFileTitle($result['title'], $dimensions);
         }
     }
     $title = SpecialPage::getTitleFor("Search");
     $results['videoUrl'] = $title->getLocalURL(['ns6' => 1, 'fulltext' => 'Search', 'search' => $query, 'filters[]' => $videoOnly ? 'is_video' : '']);
     $response = $this->getResponse();
     $response->setFormat('json');
     $response->setData($results);
 }