/** * Accepts a Solarium select result and a search config. * If not the root search result set, you should provide the parent and metaposition. * @param Solarium_Result_Select $result * @param WikiaSearchConfig $searchConfig * @param WikiaSearchResultSet $parent * @param int $metaposition */ public function __construct(Solarium_Result_Select $result, WikiaSearchConfig $searchConfig, $parent = null, $metaposition = null) { wfProfileIn(__METHOD__); parent::__construct(); $this->searchResultObject = $result; $this->searchConfig = $searchConfig; $this->setQuery($searchConfig->getQuery(WikiaSearchConfig::QUERY_ENCODED)); if ($result instanceof Solarium_Result_Select_Empty) { return; } if ($parent === null && $this->searchConfig->getGroupResults()) { $this->setResultGroupings($result, $searchConfig); $this->setResultsFound($this->getHostGrouping()->getMatches()); } else { $this->parent = $parent; $this->metaposition = $metaposition; $this->highlightingObject = $result->getHighlighting(); $this->setResultsStart($result->getStart())->setQueryTime($result->getQueryTime()); if ($this->parent !== null && $this->metaposition !== null) { $this->prepareChildResultSet(); } else { // default behavior for an ungrouped search result set $this->prependArticleMatchIfExists()->setResults($this->searchResultObject->getDocuments())->setResultsFound($this->resultsFound + $this->searchResultObject->getNumFound()); } } wfProfileOut(__METHOD__); }
/** * Countable implementation * * @return int */ public function count() { // if no results are available yet, get them now if (null == $this->_result) { $this->_fetchNext(); } return $this->_result->getNumFound(); }
public function testGetNumFound() { $this->assertEquals($this->_numFound, $this->_result->getNumFound()); }
/** * @desc Returns first document from results set * * @param Solarium_Result_Select $resultSet * @return null */ private function getFirstResult($resultSet) { if ($resultSet->getNumFound()) { foreach ($resultSet as $document) { return $document; } } return null; }