PHP code example of friendsofcat / opensearch-scout-driver

1. Go to this page and download the library: Download friendsofcat/opensearch-scout-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/ */

    

friendsofcat / opensearch-scout-driver example snippets


// config/scout.php

'driver' => env('SCOUT_DRIVER', 'opensearch'),

$orders = App\Order::search('title:(Star OR Trek)')->get();

$orders = App\Order::search()->where('user_id', 1)->get();

public function shouldBeSearchable()
{
    return count($this->toSearchableArray()) > 0;
}

$searchResult = App\Order::search('Star Trek')->raw();

App\Order::search('Star Trek', function () {
    // this will not be triggered
})->get()
bash
php artisan vendor:publish --provider="Laravel\Scout\ScoutServiceProvider"
bash
php artisan vendor:publish --provider="OpenSearch\Laravel\Client\ServiceProvider"
bash
php artisan vendor:publish --provider="OpenSearch\ScoutDriver\ServiceProvider"