protected function getNewArticlesFromSolr($ns, $limit, $minArticleQuality)
 {
     $searchConfig = new Wikia\Search\Config();
     $searchConfig->setQuery('*')->setLimit($limit)->setRank('default')->setOnWiki(true)->setWikiId($this->wg->wgCityId)->setNamespaces($ns)->setMinArticleQuality($minArticleQuality)->setRank(\Wikia\Search\Config::RANK_NEWEST_PAGE_ID)->setRequestedFields(['html_en']);
     $results = (new Factory())->getFromConfig($searchConfig)->searchAsApi(['pageid' => 'id', 'ns', 'title_en' => 'title', 'html_en' => 'abstract', 'article_quality_i' => 'quality'], false, 'pageid');
     return $results;
 }
Ejemplo n.º 2
0
 protected function getConfigById($wikiId, $articleId)
 {
     $searchConfig = new Config();
     $searchConfig->setQuery('*')->setLimit(1)->setPage(1)->setWikiId((int) $wikiId)->setVideoSearch(false)->setOnWiki(true)->setPageId((int) $articleId)->setNamespaces([self::NAMESPACE_SETTING]);
     return $searchConfig;
 }
 /**
  * Returns wikia Config for cross wiki search build on request data
  * @return Wikia\Search\Config
  */
 protected function getConfigCrossWiki()
 {
     $request = $this->getRequest();
     $searchConfig = new Wikia\Search\Config();
     $lang = $request->getArray('lang');
     if (in_array(self::ALL_LANGUAGES_STR, $lang)) {
         $lang = ['*'];
     }
     $searchConfig->setQuery($request->getVal('query', null))->setLimit($request->getInt('limit', static::CROSS_WIKI_LIMIT))->setPage($request->getVal('batch', 1))->setRank($request->getVal('rank', 'default'))->setHub($request->getArray('hub', null))->setInterWiki(true)->setCommercialUse($this->hideNonCommercialContent());
     if (!empty($lang)) {
         $searchConfig->setLanguageCode($lang);
     }
     //this will set different boosting
     $searchConfig->setBoostGroup('CrossWikiApi');
     return $searchConfig;
 }
Ejemplo n.º 4
0
 /**
  * @param $query
  * @param $hubs
  * @param $lang
  * @return array
  */
 public function queryForWikias($query, $hubs, $lang)
 {
     $crossWikiSearchConfig = new Config();
     $crossWikiSearchConfig->setQuery($query)->setLimit(self::CROSS_WIKI_RESULTS)->setPage(1)->setRank('default')->setInterWiki(true)->setCommercialUse($this->getHideNonCommercialContent())->setLanguageCode($lang);
     if (!empty($hubs)) {
         $crossWikiSearchConfig->setHubs($hubs);
     }
     $crossWikiResultSet = (new Factory())->getFromConfig($crossWikiSearchConfig)->search();
     $crossWikiResults = $crossWikiResultSet->toArray(["sitename_txt", "url", "id", "description_txt", "lang_s", "score", "description_txt"]);
     return $crossWikiResults;
 }
Ejemplo n.º 5
0
 /**
  * @group Slow
  * @slowExecutionTime 0.07538 ms
  * @covers \Wikia\Search\Config::getQuery
  */
 public function testGetQuery()
 {
     $config = new \Wikia\Search\Config();
     $this->assertNull($config->getQuery());
     $query = "foo and: bar & baz";
     $config->setQuery($query);
     $this->assertInstanceOf('Wikia\\Search\\Query\\Select', $config->getQuery());
     $this->assertAttributeContains($query, 'rawQuery', $config->getQuery());
     $config = new \Wikia\Search\Config(['query' => 'foo']);
     $this->assertInstanceOf('Wikia\\Search\\Query\\Select', $config->getQuery());
 }