コード例 #1
0
ファイル: ResultTest.php プロジェクト: lhess/solarium
 public function testGetInvalidData()
 {
     $data = 'invalid';
     $this->response = new Response($data, $this->headers);
     $this->result = new Result($this->client, $this->query, $this->response);
     $this->setExpectedException('Solarium\\Exception\\UnexpectedValueException');
     $this->result->getData();
 }
コード例 #2
0
ファイル: Field.php プロジェクト: starsw001/solarium
 /**
  * Parse analysis types and items.
  *
  * @param Result $result
  * @param array  $typeData
  *
  * @return Types[]
  */
 protected function parseTypes($result, $typeData)
 {
     $query = $result->getQuery();
     $results = array();
     foreach ($typeData as $fieldKey => $fieldData) {
         $types = array();
         foreach ($fieldData as $typeKey => $typeData) {
             if ($query->getResponseWriter() == $query::WT_JSON) {
                 // fix for extra level for key fields
                 if (count($typeData) == 1) {
                     $typeData = current($typeData);
                 }
                 $typeData = $this->convertToKeyValueArray($typeData);
             }
             $classes = array();
             foreach ($typeData as $class => $analysis) {
                 if (is_string($analysis)) {
                     $item = new Item(array('text' => $analysis, 'start' => null, 'end' => null, 'position' => null, 'positionHistory' => null, 'type' => null));
                     $classes[] = new ResultList($class, array($item));
                 } else {
                     $items = array();
                     foreach ($analysis as $itemData) {
                         $items[] = new Item($itemData);
                     }
                     $classes[] = new ResultList($class, $items);
                 }
             }
             $types[] = new ResultList($typeKey, $classes);
         }
         $results[] = new Types($fieldKey, $types);
     }
     return $results;
 }
コード例 #3
0
 /**
  * Transform Solr result into a Tao ResultSet
  * 
  * @param Result $solrResult
  * @return \oat\tao\model\search\ResultSet
  */
 protected function buildResultSet(Result $solrResult)
 {
     $uris = array();
     foreach ($solrResult as $document) {
         $uris[] = $document->uri;
         //.' : '.implode(',',$document->label);
     }
     return new ResultSet($uris, $solrResult->getNumFound());
 }