Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.78 KB | None | 0 0
  1. use Aws\CloudSearch\CloudSearchClient;
  2. use \Config;
  3.  
  4. public function index()
  5. {
  6.     $cloudSearchClient = CloudSearchClient::factory(Config::get("wdna-aws::cloudsearch"));
  7.  
  8.     $domainClient = $cloudSearchClient->getDomainClient(
  9.         'catalog-items',
  10.         ['credentials' => Config::get("wdna-aws::cloudsearch")]
  11.     );
  12.  
  13.     $result = $domainClient->search([
  14.         'query' => 'matchall',
  15.         'queryParser' => 'structured',
  16.         'size' => '100'
  17.     ])->toArray();
  18.  
  19.     foreach ($result['hits']['hit'] as $hit) {
  20.         $documents[] = [
  21.             'type' => 'delete',
  22.             'id' => $hit['id']
  23.         ];
  24.     }
  25.     $domainClient->uploadDocuments([
  26.         'contentType' => 'application/json',
  27.         'documents' => json_encode($documents)
  28.     ]);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement