PHP code example of bytexr / laravel-scout-opensearch

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

    

bytexr / laravel-scout-opensearch example snippets


return [
    ...

    'opensearch' => [
        'host' => env('OPENSEARCH_HOST', 'https://localhost:9200'),
        'access_key' => env('OPENSEARCH_ACCESS_KEY', 'admin'),
        'secret_key' => env('OPENSEARCH_SECRET_KEY', 'admin'),
        'options' => [
            'ssl_verification' => env('OPENSEARCH_SSL_VERIFICATION', true),
            // Used for AWS
            'sigv4_enabled' => env('OPENSEARCH_SIGV4_ENABLED', false),
            'sigv4_region' =>  env('OPENSEARCH_SIGV4_REGION', 'eu-west-1'),
        ],
    ],

];


return [
    ...
    
    'opensearch' => [
        ...
        'index-settings' => [
            Post::class => [
                'mappings' => [
                    'properties' => [
                        'id' => [
                            'type' => 'text',
                        ],
                        'title' => [
                            'type' => 'text',
                        ],
                    ],
                ],
            ],
        ],
    ]
]