Created
October 30, 2013 10:21
-
-
Save hoffigk/7230240 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Loads all data into the results object (initialisation) | |
* | |
* @param \Elastica\Response $response Response object | |
*/ | |
protected function _init(Response $response) | |
{ | |
$this->_response = $response; | |
$result = $response->getData(); | |
$this->_totalHits = isset($result['hits']['total']) ? $result['hits']['total'] : 0; | |
$this->_maxScore = isset($result['hits']['max_score']) ? $result['hits']['max_score'] : 0; | |
$this->_took = isset($result['took']) ? $result['took'] : 0; | |
$this->_timedOut = !empty($result['timed_out']); | |
if (isset($result['hits']['hits'])) { | |
foreach ($result['hits']['hits'] as $hit) { | |
$this->_results[] = new Result($hit); | |
} | |
} | |
if (isset($result['suggest'])) { | |
foreach($result['suggest'] as $suggestName => $suggest) { | |
if(isset($suggest[0]['options']) && count($suggest[0]['options'])>0) { | |
$this->_suggests[$suggestName] = $suggest[0]; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment