* @license http://github.com/basdenooijer/solarium/raw/master/COPYING * @link http://www.solarium-project.org/ * * @package Solarium * @subpackage Client */ /** * Parse MoreLikeThis response data * * @package Solarium * @subpackage Client */ class Solarium_Client_ResponseParser_MoreLikeThis extends Solarium_Client_ResponseParser_Select { /** * Get result data for the response * * @param Solarium_Result_MoreLikeThis $result * @return array */ public function parse($result) { $data = $result->getData(); $query = $result->getQuery(); $parseResult = parent::parse($result); if (isset($data['interestingTerms']) && 'none' != $query->getInterestingTerms()) { $terms = $data['interestingTerms']; if ('details' == $query->getInterestingTerms()) { $tempTerms = array(); for ($i = 0; $i < count($terms); $i += 2) { $tempTerms[$terms[$i]] = $terms[$i + 1]; } $terms = $tempTerms; } $parseResult['interestingTerms'] = $terms; } if (isset($data['match']['docs'][0]) && true == $query->getMatchInclude()) { $matchData = $data['match']['docs'][0]; $documentClass = $query->getOption('documentclass'); $fields = (array)$matchData; $parseResult['match'] = new $documentClass($fields); } return $parseResult; } }