protected function prepareQuery($query) { $this->getBlacklist()->addBlacklistedHostsProvider(BlacklistFilter::staticProvider($this->blacklistedWikiHosts)); $select = $this->getSelect(); $phrase = $this->sanitizeQuery($query); $slang = $this->sanitizeQuery($this->getLang()); $dismax = $select->getDisMax(); $dismax->setQueryParser('edismax'); $select->setQuery('+("' . $phrase . '") AND +(lang_s:' . $slang . ')'); $select->setRows(static::WIKI_LIMIT); $select = $this->getBlacklist()->applyFilters($select); $select->createFilterQuery('articles')->setQuery('articles_i:[' . static::MINIMAL_WIKIA_ARTICLES . ' TO *]'); $dismax->setQueryFields('series_mv_tm^15 description_txt categories_txt top_categories_txt top_articles_txt ' . 'sitename_txt^2 all_domains_mv_wd^5'); $dismax->setPhraseFields('series_mv_tm^15 sitename_txt^2 all_domains_mv_wd^5'); $dismax->setBoostFunctions('wam_i^4'); $dismax->setQueryPhraseSlop(static::DEFAULT_SLOP); $dismax->setPhraseSlop(static::DEFAULT_SLOP); return $select; }
protected function prepareQuery($query) { $this->getBlacklist()->addBlacklistedHostsProvider(BlacklistFilter::staticProvider(self::$HOSTS_BLACKLIST)); $select = $this->getSelect(); $phrase = $this->sanitizeQuery($query); $slang = $this->sanitizeQuery($this->getLang()); $preparedQuery = $this->createQuery($phrase); $dismax = $select->getDisMax(); $dismax->setQueryParser('edismax'); $select->setQuery($preparedQuery); $select->setRows(static::ARTICLES_LIMIT); $select = $this->getBlacklist()->applyFilters($select); $select->createFilterQuery('ns')->setQuery('+(ns:' . static::ALLOWED_NAMESPACE . ')'); $select->createFilterQuery('lang')->setQuery('+(lang:' . $slang . ')'); if (in_array(strtolower($slang), static::$ARTICLE_TYPES_SUPPORTED_LANGS)) { $select->createFilterQuery('type')->setQuery('+(article_type_s:' . static::MOVIE_TYPE . ' OR ' . static::EXACT_MATCH_FIELD . ':*)'); } $dismax->setQueryFields(implode(' ', ['title_em^10', 'titleStrict', $this->withLang('title', $slang), $this->withLang('redirect_titles_mv', $slang), static::EXACT_MATCH_FIELD . "^10"])); $dismax->setPhraseFields(implode(' ', ['titleStrict^8', $this->withLang('title', $slang) . '^2', $this->withLang('redirect_titles_mv', $slang) . '^2', static::EXACT_MATCH_FIELD . "^10"])); return $select; }