Skip to content

Instantly share code, notes, and snippets.

@teepluss
Last active May 7, 2019 15:54
Show Gist options
  • Save teepluss/cdc003544f290899568f4a77c5a47657 to your computer and use it in GitHub Desktop.
Save teepluss/cdc003544f290899568f4a77c5a47657 to your computer and use it in GitHub Desktop.
Example CloudSearch
<?php
use Aws\CloudSearch\CloudSearchClient;
use Aws\CloudSearchDomain\CloudSearchDomainClient;
// http://docs.aws.amazon.com/aws-sdk-php/v2/guide/service-cloudsearchdomain.html
$client = CloudSearchDomainClient::factory(array(
//'endpoint' => 'https://doc-example-xxx.ap-southeast-1.cloudsearch.amazonaws.com',
'endpoint' => 'https://search-example-xxx.ap-southeast-1.cloudsearch.amazonaws.com',
'validation' => false,
'version' => 'latest',
'credentials' => [
'key' => '[KEY] ',
'secret' => '[SECRET]',
],
'region' => 'ap-southeast-1',
));
$batch = [
[
'type' => 'add',
'id' => 1,
'fields' => ['title' => 'ข้อมูลเพื่อการค้น']
],
[
'type' => 'add',
'id' => 2,
'fields' => ['title' => 'สุดยอดครับ แบบนี้ผมจะทำอะไร']
]
];
/*
$result = $client->uploadDocuments([
'documents' => json_encode($batch),
'contentType' =>'application/json'
]);
*/
// Use the search operation
$result = $client->search(array('query' => 'ผม'));
$hitCount = $result->getPath('hits/found');
dump("Hits: {$hitCount}", $result);
@cristal2431
Copy link

Do you have this in version 3?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment