PHP code example of novius / laravel-scout-elasticsearch-driver

1. Go to this page and download the library: Download novius/laravel-scout-elasticsearch-driver library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

novius / laravel-scout-elasticsearch-driver example snippets


$results = MyModel::search('keywords')->get();
foreach ($results as $result) {
    // Score is now available in : $result->_score
}



return [

    ...
    
    'channels' => [

        ...

        'es' => [
            'driver' => 'daily',
            'path' => storage_path('logs/es.log'),
            'level' => 'debug',
            'days' => 5,
        ],
    ],
];



return [
    'client' => [
        'hosts' => [
            env('SCOUT_ELASTIC_HOST', 'localhost:9200'),
        ],
    ],
    'document_refresh' => env('SCOUT_ELASTIC_DOCUMENT_REFRESH'),
    'searchable_models' => [],
    'log_enabled' => env('SCOUT_ELASTIC_LOG_ENABLED', false),
    'log_channels' => [],
];

php artisan vendor:publish --provider="Laravel\Scout\ScoutServiceProvider"
php artisan vendor:publish --provider="Novius\ScoutElastic\ScoutElasticServiceProvider"