zing / laravel-scout-opensearch
Laravel Scout custom engine for OpenSearch
Fund package maintenance!
www.paypal.com/paypalme/zingimmick
Installs: 73 373
Dependents: 0
Suggesters: 0
Security: 0
Stars: 21
Watchers: 1
Forks: 6
Open Issues: 1
Requires
- php: ^8.0
- ext-json: *
- laravel/scout: ^8.5 || ^9.1 || ^10.0
- opensearch-project/opensearch-php: ^2.0
Requires (Dev)
- mockery/mockery: ~1.3.3 || ^1.4.2
- nunomaduro/larastan: ^1.0 || ^2.0
- orchestra/testbench: ^4.5 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0
- phpstan/phpstan-mockery: ^1.0
- phpunit/phpunit: ^9.3.3 || ^10.0 || ^11.0
- zing/coding-standard: ^6.4 || ^7.0
README
Requires PHP 8.0+
Require Laravel Scout OpenSearch using Composer:
composer require zing/laravel-scout-opensearch
Configuration
return [ // ... 'opensearch' => [ 'hosts' => [env('OPENSEARCH_HOST', 'localhost:9200')], 'basicAuthentication' => [env('OPENSEARCH_USERNAME', 'admin'), env('OPENSEARCH_PASSWORD', 'admin')], 'retries' => env('OPENSEARCH_RETRYS', 2), ], ];
Set app name and table name for model
class SearchableModel extends Model { use Searchable; public function searchableAs(): string { return 'searchable_models_index'; } /** * @return array{id: mixed} */ public function toSearchableArray(): array { return [ 'id' => $this->getScoutKey(), ]; } }
Configuration for Amazon OpenSearch Service
return [ // ... 'opensearch' => [ 'hosts' => [env('OPENSEARCH_HOST', 'localhost:9200')], 'basicAuthentication' => [env('OPENSEARCH_USERNAME', 'admin'), env('OPENSEARCH_PASSWORD', 'admin')], 'retries' => env('OPENSEARCH_RETRYS', 2), 'sigV4Region' => env('OPENSEARCH_REGION', 'us-east-1') , 'sigV4Service' => env('OPENSEARCH_SERVICE', 'es') , 'sigV4CredentialProvider' => [ 'key' => env('OPENSEARCH_IAM_KEY'), 'secret' => env('OPENSEARCH_IAM_SECRET'), ], ], ];
Debug and logging
return [ // ... 'opensearch' => [ 'hosts' => [env('OPENSEARCH_HOST', 'localhost:9200')], 'basicAuthentication' => [env('OPENSEARCH_USERNAME', 'admin'), env('OPENSEARCH_PASSWORD', 'admin')], 'retries' => env('OPENSEARCH_RETRYS', 2), 'logger' => (new \Monolog\Logger('opensearch'))->pushHandler(new \Monolog\Handler\RotatingFileHandler('opensearch.log')), 'tracer' => (new \Monolog\Logger('opensearch'))->pushHandler(new \Monolog\Handler\RotatingFileHandler('opensearch.log')), ], ];
License
Laravel Scout OpenSearch is an open-sourced software licensed under the MIT license.