PHP code example of phoogkamer / cloudsearch-wrapper

1. Go to this page and download the library: Download phoogkamer/cloudsearch-wrapper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

phoogkamer / cloudsearch-wrapper example snippets


$client = new CloudSearchClient($endpoint, $key, $secret);

$query = new CloudSearchStructuredQuery();

//Adds a field (id:1)
$query->addField('id', 1);

//Will give max 15 results
$query->setSize(15);

//Currently $result is still the standard AWS SDK result
$result = $client->search($query);

$query->addAnd(function(CloudSearchStructuredQuery $query)
{
    $query->addOr(function(CloudSearchStructuredQuery $query)
    {
        //Add string by setting the second parameter true
        $query->addField('title', 'Forged Alliance', true);

        $query->addField('title', 'Supreme Commander', true);
    });

    $query->addOr(function(CloudSearchStructuredQuery $query)
    {
        $query->addField('id', 1);

        //Gets everything within a range from 2 to 5
        $query->addRangeField('id', 2, 5);
    });
});