Download the PHP package pascalvgemert/laravel-cloud-search without Composer
On this page you can find all versions of the php package pascalvgemert/laravel-cloud-search. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pascalvgemert/laravel-cloud-search
More information about pascalvgemert/laravel-cloud-search
Files in pascalvgemert/laravel-cloud-search
Package laravel-cloud-search
Short Description A package to use CloudSearch in an Eloquent way within Laravel
License GPL-3.0-or-later
Homepage https://github.com/pascalvgemert/laravel-cloud-search
Informations about the package 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!
Installation
You can install the package via composer:
To install the AWS package follow the steps in the README.md on: AWS Service Provider for Laravel 5 & 6
Usage
Instead of using Models, you create Documents. They almost work the same as a Model Class.
Example:
Now you can use this Document to query it like you would query an Eloquent model.
Example:
Extra CloudSearch Methods
Method | Example |
---|---|
phrase |
Product::query()->phrase('Nemo')->get(); (see section: Searching below for more details) |
whereLiteral |
Product::query()->whereLiteral('type', 'game')->get(); |
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
In Laravel you can listen to the Event as follows:
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
A much used functionality of CloudSearch is the use of Facets / Buckets. This can easily be taking in account while making your query:
Statistics (stats)
The same goes for Statistics or stats as they're called in AWS CloudSearch:
All versions of laravel-cloud-search with dependencies
illuminate/contracts Version ^5.5|^6|^7|^8
illuminate/support Version ^5.5|^6|^7|^8
aws/aws-sdk-php Version ^3.0