PHPackages                             pascalvgemert/laravel-cloud-search - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. pascalvgemert/laravel-cloud-search

ActiveLibrary[Database &amp; ORM](/categories/database)

pascalvgemert/laravel-cloud-search
==================================

A package to use CloudSearch in an Eloquent way within Laravel

0.4.0(5y ago)28.7k↑153.3%1GPL-3.0-or-laterPHPPHP &gt;=7.1

Since Mar 19Pushed 5y ago1 watchersCompare

[ Source](https://github.com/pascalvgemert/laravel-cloud-search)[ Packagist](https://packagist.org/packages/pascalvgemert/laravel-cloud-search)[ Docs](https://github.com/pascalvgemert/laravel-cloud-search)[ RSS](/packages/pascalvgemert-laravel-cloud-search/feed)WikiDiscussions master Synced yesterday

READMEChangelog (3)Dependencies (3)Versions (17)Used By (0)

laravel-cloud-search
====================

[](#laravel-cloud-search)

An Eloquent way to use CloudSearch within Laravel

### Requires PHP 7.1, Laravel 5.5 or higher and the Laravel AWS package!

[](#requires-php-71-laravel-55-or-higher-and-the-laravel-aws-package)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require pascalvgemert/laravel-cloud-search
```

To install the AWS package follow the steps in the README.md on: [AWS Service Provider for Laravel 5 &amp; 6](https://github.com/aws/aws-sdk-php-laravel)

Usage
-----

[](#usage)

Instead of using Models, you create Documents. They almost work the same as a Model Class.

Example:

```
use LaravelCloudSearch\Contracts\FieldType;
use LaravelCloudSearch\Document;
/**
 * Define your CloudSearch index fields here, this will help to define default values in your document result:
 *
 * @property-read int $id
 * @property-read string $title
 * @property-read string $description
 * @property-read string $country_code
 * @property-read array $images
 * @property-read int $stock
 * @property-read bool $pre_order
 */
class Product extends Document
{
    /** @var string */
    protected $domain = 'http://your-domain-url-for-cloudsearch.eu-west-1.cloudsearch.amazonaws.com';

    /** @var array */
    protected $casts = [
        'images' => FieldType::ARRAY,
        'pre_order' => FieldType::BOOL,
        'searchable' => FieldType::BOOL,
    ];
}
```

Now you can use this Document to query it like you would query an Eloquent model.

Example:

```
/** @var \LaravelCloudSearch\DocumentCollection|\LaravelCloudSearch\Document[] **/
$products = Product::query()
    ->select('id')
    ->where('country_code', 'NL')
    ->where(function ($query) {
        $query
            ->where('stock', '>', 0)
            ->orWhere('pre_order', 1);
    })
    ->orderBy('price', 'asc')
    ->take(10)
    ->get();
```

### Extra CloudSearch Methods

[](#extra-cloudsearch-methods)

MethodExample`phrase``Product::query()->phrase('Nemo')->get();` *(see section: Searching below for more details)*`whereLiteral``Product::query()->whereLiteral('type', 'game')->get();`Debugging
---------

[](#debugging)

To debug your build query, you can use the `getQuery()` method just like Eloquent.

Another great feature is that you can hook into the `cloudsearch.query` event. The event contains the `time` it took to execute the query at CloudSearch, which `arguments` where used and the `trace` from the place the query got executed. For example you can hook the CloudSearch queries into the [Laravel-Debugbar](https://github.com/barryvdh/laravel-debugbar)

**In Laravel you can listen to the Event as follows:**

```
Event::listen('cloudsearch.query', function ($timeInMilliSeconds, $arguments, $trace) {
    dump($timeInMilliSeconds, $arguments, $trace);
});

```

Searching
---------

[](#searching)

To fuzzy search you can use the `phrase(string $searchPhrase, int|float $fuzziness = null, bool $lookForAnyWord = false)` method.

The `$fuzziness` is a decimal percentage 0 to 1 where the default is 0.25. The `$lookForAnyWord` is a boolean to search for all or any words, default is all words.

Facets
------

[](#facets)

A much used functionality of CloudSearch is the use of Facets / Buckets. This can easily be taking in account while making your query:

```
/** @var \LaravelCloudSearch\DocumentCollection **/
$products = Product::facet('country_code', ['size' => 10])->get();

/** @var \Illuminate\Support\Collection|\LaravelCloudSearch\Facet[] **/
$productFacets = $products->getFacets();
```

Statistics (stats)
------------------

[](#statistics-stats)

The same goes for Statistics or stats as they're called in AWS CloudSearch:

```
/** @var \LaravelCloudSearch\DocumentCollection **/
$products = Product::statistics('country_code')->get();

/** @var \Illuminate\Support\Collection **/
$productStatistics = $products->getStatistics();
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~32 days

Recently: every ~86 days

Total

12

Last Release

1940d ago

PHP version history (2 changes)0.1.0PHP &gt;=7.0

0.4.0PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/609e8d7caaa1dacc8b03bcc8347b5732e5a91399bb843e5b44fec66be256f35a?d=identicon)[pascalvgemert](/maintainers/pascalvgemert)

---

Top Contributors

[![pascalvgemert](https://avatars.githubusercontent.com/u/1567379?v=4)](https://github.com/pascalvgemert "pascalvgemert (29 commits)")

---

Tags

awseloquentelastic searchcloudsearchpascalvgemertcloud-searchaws cloudsearch

### Embed Badge

![Health badge](/badges/pascalvgemert-laravel-cloud-search/health.svg)

```
[![Health](https://phpackages.com/badges/pascalvgemert-laravel-cloud-search/health.svg)](https://phpackages.com/packages/pascalvgemert-laravel-cloud-search)
```

###  Alternatives

[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M194](/packages/laravel-ai)[illuminate/database

The Illuminate Database package.

2.8k54.9M11.6k](/packages/illuminate-database)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M345](/packages/psalm-plugin-laravel)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45444.2k1](/packages/pressbooks-pressbooks)[watson/validating

Eloquent model validating trait.

9803.5M54](/packages/watson-validating)[moonshine/moonshine

Laravel administration panel

1.3k253.1k81](/packages/moonshine-moonshine)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
