alejandroakbal / laravel-scout-advanced-meilisearch
Laravel Scout extension that allows to use meilisearch advanced features as well as has an extended collection driver for testing purposes.
Installs: 14
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 4
Type:laravel-package
Requires
- php: ^8.0 || ^8.1 || ^8.2
- laravel/framework: ^10.0.0
- laravel/scout: ^10.0.0
- meilisearch/meilisearch-php: ^1.0.0
Requires (Dev)
- orchestra/testbench: ^8.5
- roave/security-advisories: dev-latest
README
What this package provides
Extended scout query builder
Added next changes to the basic query builder:
where('column', '<=', $value)
- extended where, which supports 3 optional parameters for comparison. Two parameters are also allowed.where(Clusure $query)
- where can take a closure as the first parameter in order to group queries (the same fororWhere
)whereBetween('column', [$value1, $value2])
whereNotIn('column', [$value1, $value2, $value3])
- All where clauses have or variant:
orWhere
,orWhereIn
, etc
Two scout drivers
The drivers are compatible with the new scout builder.
- meilisearch_advanced
- collection_advanced
meilisearch_advanced
Uses all the advantages of meilisearch for comparison the results, searching in indexed arrays.
Also fixes an issue with the calculation of the total number of values.
(The current implementation requests the entire dataset in case scout builder has ->query()
method used)
collection_advanced
The driver imitates how meilisearch work and completely relies on collections. It should be used only for tests as the whole searchable models data is in memory. The driver allows testing filtering and sorting as well as Extended scout builder features.
How to use?
- In
config/scout.php
set'driver'
tomeilisearch_advanced
orcollection_advanced
(for tests)
Development
PHP
Use PHP with Docker
docker run --rm \ -u "$(id -u):$(id -g)" \ -v "$(pwd):/var/www/html" \ -w /var/www/html \ laravelsail/php82-composer:latest \ composer install
Run tests
docker run --rm \ -u "$(id -u):$(id -g)" \ -v "$(pwd):/var/www/html" \ -w /var/www/html \ laravelsail/php82-composer:latest \ composer test
Publish
You can publish a package version with:
git tag -a 1.0.0 -m "First release"
git push --tags