protected function setUp()
 {
     parent::setUp();
     $hash = hash('crc32', __CLASS__);
     $bucket = sprintf('test_riak_client_%s_search_mapreduce_bucket', $hash);
     $index = sprintf('test_riak_client_%s_search_mapreduce_index', $hash);
     $namespace = new RiakNamespace('thunder_cats', $bucket);
     $data = new ThunderCatsData($this->client, $namespace, $index);
     $this->searchData = $data;
     $this->indexName = $index;
     $this->namespace = $namespace;
     $this->searchData->setUp();
     $this->searchData->storeThunderCats();
 }
Esempio n. 2
0
 public function testSearchReturnFields()
 {
     $this->searchData->storeThunderCats();
     $index = $this->indexName;
     $search = Search::builder()->withReturnFields(['name_s', 'age_i'])->withQuery('age_i:30')->withIndex($index)->withNumRows(10)->build();
     $searchResult = $this->client->execute($search);
     $this->assertInstanceOf('Riak\\Client\\Command\\Search\\Response\\SearchResponse', $searchResult);
     $numResults = $searchResult->getNumResults();
     $results = $searchResult->getSingleResults();
     usort($results, function ($arg1, $arg2) {
         return strcmp($arg2['name_s'], $arg1['name_s']);
     });
     $this->assertCount(2, $results);
     $this->assertEquals(2, $numResults);
     $this->assertCount(2, $results[0]);
     $this->assertCount(2, $results[1]);
     $this->assertEquals(30, $results[0]['age_i']);
     $this->assertEquals(30, $results[1]['age_i']);
     $this->assertEquals('Lion-o', $results[0]['name_s']);
     $this->assertEquals('Cheetara', $results[1]['name_s']);
 }