/**
  * @return \Riak\Client\Core\Message\Search\PutIndexRequest
  */
 private function createPutIndexRequest()
 {
     $request = new PutIndexRequest();
     $request->nVal = $this->schema->getNVal();
     $request->name = $this->schema->getName();
     $request->schema = $this->schema->getSchema();
     return $request;
 }
 /**
  * {@inheritdoc}
  */
 public function execute(RiakTransport $adapter)
 {
     $schema = null;
     $response = $adapter->send($this->createGetIndexRequest());
     if ($response && $response->name) {
         $schema = new YokozunaIndex($response->name, $response->schema);
         $schema->setNVal($response->nVal);
     }
     return new FetchIndexResponse($schema);
 }
示例#3
0
 /**
  * @deprecated
  *
  * not worth functional testing
  * Riak will fail to fetch the index for a couple seconds after store
  */
 public function testStoreAndFetchIndex()
 {
     $indexName = 'schedule_' . uniqid();
     $index = new YokozunaIndex($indexName, '_yz_default');
     $index->setNVal(3);
     $store = StoreIndex::builder()->withIndex($index)->build();
     $fetch = FetchIndex::builder()->withIndexName($indexName)->build();
     $delete = DeleteIndex::builder()->withIndexName($indexName)->build();
     $storeResponse = $this->client->execute($store);
     $fetchResponse = $this->retryCommand($fetch, 10);
     $deleteResponse = $this->client->execute($delete);
     $this->assertInstanceOf('Riak\\Client\\Command\\Search\\Response\\StoreIndexResponse', $storeResponse);
     $this->assertInstanceOf('Riak\\Client\\Command\\Search\\Response\\FetchIndexResponse', $fetchResponse);
     $this->assertInstanceOf('Riak\\Client\\Command\\Search\\Response\\DeleteIndexResponse', $deleteResponse);
 }
 public function testExecuteOperation()
 {
     $response = new PutIndexResponse();
     $index = new YokozunaIndex(null, null);
     $operation = new StoreIndexOperation($index);
     $callback = function ($subject) {
         $this->assertInstanceOf('Riak\\Client\\Core\\Message\\Search\\PutIndexRequest', $subject);
         $this->assertEquals('schema-name', $subject->schema);
         $this->assertEquals('index-name', $subject->name);
         return true;
     };
     $index->setName('index-name');
     $index->setSchema('schema-name');
     $this->adapter->expects($this->once())->method('send')->willReturn($response)->with($this->callback($callback));
     $this->assertInstanceOf('Riak\\Client\\Command\\Search\\Response\\StoreIndexResponse', $operation->execute($this->adapter));
 }