PHPackages                             torann/laravel-cloudsearch - 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. torann/laravel-cloudsearch

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

torann/laravel-cloudsearch
==========================

Index and search Laravel models on Amazon's CloudSearch.

0.1.5(8y ago)2214.1k10[4 issues](https://github.com/Torann/laravel-cloudsearch/issues)[2 PRs](https://github.com/Torann/laravel-cloudsearch/pulls)BSD 2-ClausePHPPHP &gt;=5.6.4

Since Jun 18Pushed 6y ago1 watchersCompare

[ Source](https://github.com/Torann/laravel-cloudsearch)[ Packagist](https://packagist.org/packages/torann/laravel-cloudsearch)[ Docs](https://github.com/Torann/laravel-cloudsearch)[ RSS](/packages/torann-laravel-cloudsearch/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (5)Versions (7)Used By (0)

Laravel CloudSearch
===================

[](#laravel-cloudsearch)

[![Latest Stable Version](https://camo.githubusercontent.com/98514b188dda1b9feebfe206250995e90eb7d9316db9430e82f35a14e5b0fe8b/68747470733a2f2f706f7365722e707567782e6f72672f746f72616e6e2f6c61726176656c2d636c6f75647365617263682f762f737461626c652e706e67)](https://packagist.org/packages/torann/laravel-cloudsearch)[![Total Downloads](https://camo.githubusercontent.com/6e3cafee4f41df0d20b70bed816c6a7e536849d94f469450e17bab1682e7e74f/68747470733a2f2f706f7365722e707567782e6f72672f746f72616e6e2f6c61726176656c2d636c6f75647365617263682f646f776e6c6f6164732e706e67)](https://packagist.org/packages/torann/laravel-cloudsearch)[![Patreon donate button](https://camo.githubusercontent.com/f9e075baad95563481d35174d43ef50757281abb6bc795d0f473fad452afa030/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f70617472656f6e2d646f6e6174652d79656c6c6f772e737667)](https://www.patreon.com/torann)[![Donate weekly to this project using Gratipay](https://camo.githubusercontent.com/0eeae019980adaa1dc64842cfb01f3d738c688982ea4eb58094047011cb46704/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f67726174697061792d646f6e6174652d79656c6c6f772e737667)](https://gratipay.com/~torann)[![Donate to this project using Flattr](https://camo.githubusercontent.com/d79e412f78041f87e203449041ad81848a8405cf0f3c622c51e3bad0c2a4b599/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f666c617474722d646f6e6174652d79656c6c6f772e737667)](https://flattr.com/profile/torann)[![Donate to this project using Paypal](https://camo.githubusercontent.com/604e3db9c8751116b3f765aad0353ec7ded655bbe8aaacbc38d8c4a6b784b3ed/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d50617950616c2d677265656e2e737667)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4CJA2A97NPYVU)

Index and search Laravel models on Amazon's CloudSearch. To get started, you should have a basic knowledge of how CloudSearch works.

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

[](#installation)

### Composer

[](#composer)

From the command line run:

```
$ composer require torann/laravel-cloudsearch

```

### Laravel

[](#laravel)

Once installed you need to register the service provider with the application. Open up `config/app.php` and find the `providers` key.

```
'providers' => [

    LaravelCloudSearch\LaravelCloudSearchServiceProvider::class,

]
```

### Lumen

[](#lumen)

For Lumen register the service provider in `bootstrap/app.php`.

```
$app->register(LaravelCloudSearch\LaravelCloudSearchServiceProvider::class);
```

### Publish the configurations

[](#publish-the-configurations)

Run this on the command line from the root of your project:

```
$ php artisan vendor:publish --provider="LaravelCloudSearch\LaravelCloudSearchServiceProvider" --tag=config

```

A configuration file will be publish to `config/cloud-search.php`.

### Migration

[](#migration)

The package uses a batch queue system for updating the documents on AWS. This is done to help reduce the number of calls made to the API (will save money in the long run).

```
php artisan vendor:publish --provider="LaravelCloudSearch\LaravelCloudSearchServiceProvider" --tag=migrations
```

Run this on the command line from the root of your project to generate the table for storing currencies:

```
$ php artisan migrate
```

Fields
------

[](#fields)

The better help manage fields, the package ships with a simple field management command. This is completely optional, as you can manage them in the AWS console.

> **NOTE:** If you choose not to use this command to manage or setup your fields, you will still need to add the field `searchable_type` as a `literal`. This is used to store the model type.

They can be found in the `config/cloud-search.php` file under the `fields` property:

```
'fields' => [
    'title' => 'text',
    'status' => 'literal',
],
```

Artisan Commands
----------------

[](#artisan-commands)

#### `search:fields`

[](#searchfields)

Initialize an Eloquent model map.

#### `search:index `

[](#searchindex-model)

Name or comma separated names of the model(s) to index.

Arguments:

```
 model               Name or comma separated names of the model(s) to index

```

#### `search:flush `

[](#searchflush-model)

Flush all of the model documents from the index.

Arguments:

```
 model               Name or comma separated names of the model(s) to index

```

#### `search:queue`

[](#searchqueue)

Reduces the number of calls made to the CloudSearch server by queueing the updates and deletes.

Indexing
--------

[](#indexing)

Once you have added the `LaravelCloudSearch\Eloquent\Searchable` trait to a model, all you need to do is save a model instance and it will automatically be added to your index when the `search:queue` command is ran.

```
$post = new App\Post;

// ...

$post->save();
```

> **Note**: if the model document has already been indexed, then it will simply be updated. If it does not exist, it will be added.

Updating Documents
------------------

[](#updating-documents)

To update an index model, you only need to update the model instance's properties and `save`` the model to your database. The package will automatically persist the changes to your search index:

```
$post = App\Post::find(1);

// Update the post...

$post->save();
```

Removing Documents
------------------

[](#removing-documents)

To remove a document from your index, simply `delete` the model from the database. This form of removal is even compatible with **soft deleted** models:

```
$post = App\Post::find(1);

$post->delete();
```

Searching
---------

[](#searching)

You may begin searching a model using the `search` method. The search method accepts a single string that will be used to search your models. You should then chain the `get` method onto the search query to retrieve the Eloquent models that match the given search query:

```
$posts = App\Post::search('Kitten fluff')->get();
```

Since package searches return a collection of Eloquent models, you may even return the results directly from a route or controller and they will automatically be converted to JSON:

```
use Illuminate\Http\Request;

Route::get('/search', function (Request $request) {
    return App\Post::search($request->search)->get();
});
```

Pagination
----------

[](#pagination)

In addition to retrieving a collection of models, you may paginate your search results using the `paginate` method. This method will return a `Paginator` instance just as if you had paginated a traditional Eloquent query:

```
$posts = App\Post::search('Kitten fluff')->paginate();
```

You may specify how many models to retrieve per page by passing the amount as the first argument to the `paginate` method:

```
$posts = App\Post::search('Kitten fluff')->paginate(15);
```

Once you have retrieved the results, you may display the results and render the page links using Blade just as if you had paginated a traditional Eloquent query:

```

    @foreach ($posts as $post)
        {{ $post->title }}
    @endforeach

{{ $posts->links() }}
```

Basic Builder Usage
-------------------

[](#basic-builder-usage)

Initialize a builder instance:

```
$query = app(\LaravelCloudSearch\CloudSearcher::class)->newQuery();
```

You can chain query methods like so:

```
$query->phrase('ford')
    ->term('National Equipment', 'seller')
    ->range('year', '2010');
```

use the `get()` or `paginate()` methods to submit query and retrieve results from AWS.

```
$results = $query->get();
```

In the example above we did not set the search type, so this means the results that are returned will match any document on CloudSearch domain. To refine you search to certain model, either use the model like shown in the example previously or use the `searchableType()` method to set the class name of the model (this is done automatically in the model instance call):

```
$query = app(\LaravelCloudSearch\CloudSearcher::class)->newQuery();

$results = $query->searchableType(\App\LawnMower::class)
    ->term('honda', 'name')
    ->get();
```

### Search Query Operators and Nested Queries

[](#search-query-operators-and-nested-queries)

You can use the `and`, `or`, and `not` operators to build compound and nested queries. The corresponding `and()`, `or()`, and `not()` methods expect a closure as their argument. You can chain all available methods as well nest more sub-queries inside of closures.

```
$query->or(function($builder) {
    $builder->phrase('ford')
        ->phrase('truck');
});
```

Queue
-----

[](#queue)

The help reduce the number of bulk requests made to the CloudSearch endpoint (because they cost) a queue system is used. This can be set in Laravel [Task Scheduling](https://laravel.com/docs/5.4/scheduling). You can decide how often it is ran using the scheduled task frequency options. Please note this uses the DB to function.

Example of the task added to `/app/Console/Kernel.php`:

```
    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule $schedule
     *
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        $schedule->command('search:queue')->everyTenMinutes();
    }
```

Multilingual
------------

[](#multilingual)

> This feature is experimental

Laravel CloudSearch can support multiple languages by appending the language code to the index type, so when the system performs a search it will only look for data that is on in the current system locale suffixed index type. For this to work the model needs to use the `LaravelCloudSearch\Eloquent\Localized` trait or something similar to it.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity52

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 ~23 days

Recently: every ~29 days

Total

6

Last Release

3130d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b740fab755b353680beb41191f3b6195d84d9811662960d07f2bf64fde2f7c64?d=identicon)[torann](/maintainers/torann)

---

Top Contributors

[![Torann](https://avatars.githubusercontent.com/u/1406755?v=4)](https://github.com/Torann "Torann (22 commits)")

---

Tags

awscloudsearchlaravelsearchsearchlaravelawseloquentcloudsearchamazon cloudsearch

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/torann-laravel-cloudsearch/health.svg)

```
[![Health](https://phpackages.com/badges/torann-laravel-cloudsearch/health.svg)](https://phpackages.com/packages/torann-laravel-cloudsearch)
```

###  Alternatives

[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[cviebrock/eloquent-sluggable

Easy creation of slugs for your Eloquent models in Laravel

4.0k13.6M251](/packages/cviebrock-eloquent-sluggable)[cviebrock/eloquent-taggable

Easy ability to tag your Eloquent models in Laravel.

567694.8k3](/packages/cviebrock-eloquent-taggable)[mehdi-fathi/eloquent-filter

Eloquent Filter adds custom filters automatically to your Eloquent Models in Laravel.It's easy to use and fully dynamic, just with sending the Query Strings to it.

450191.6k1](/packages/mehdi-fathi-eloquent-filter)[mohammad-fouladgar/eloquent-builder

527189.5k](/packages/mohammad-fouladgar-eloquent-builder)[jedrzej/searchable

Searchable trait for Laravel's Eloquent models - filter your models using request parameters

127259.1k4](/packages/jedrzej-searchable)

PHPackages © 2026

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