/** * Creates an Apache_Solr_Document from a raw stdClass object as parsed by * SolrPhpClient. * * For compatibility reasons taken from Apache_Solr_Response->_parseData() * * @param \stdClass $rawDocument The raw document as initially returned by SolrPhpClient * @return \Apache_Solr_Document Apache Solr Document */ private function createApacheSolrDocument(\stdClass $rawDocument) { $collapseSingleValueArrays = $this->search->getSolrConnection()->getCollapseSingleValueArrays(); $document = new \Apache_Solr_Document(); foreach ($rawDocument as $key => $value) { // If a result is an array with only a single value // then its nice to be able to access it // as if it were always a single value if ($collapseSingleValueArrays && is_array($value) && count($value) <= 1) { $value = array_shift($value); } $document->{$key} = $value; } return $document; }