PHP code example of konsulting / scout-elastic-app-search

1. Go to this page and download the library: Download konsulting/scout-elastic-app-search 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/ */

    

konsulting / scout-elastic-app-search example snippets

 php
'chunk' => [
    'searchable' => 100,
    'unsearchable' => 100,
],
 php 
 $result = Model::search($searchTerm)->get();
 php
 $result = Model::search($searchTerm, function (ElasticAppProxy $elastic, $query, $options) {
    // Adjust the options here
    // E.g. set the search fields in options, and add weightings
    $options['search_fields']['field_name']['weight'] = 1;
   
   // Use filters, and so on
    $options['filters'] = [
        'all' => [
            'name' => 'Konsulting',
            'keyword' => 'Scout',
        ],
    ];

    // Manipulate the position in results
    $options['page']['size'] = $this->limit;
    $options['page']['current'] = $this->currentPage();

    return $elastic->search($query, $options);
})->get();