PHP code example of wangzd / laravel-elasticsearch

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

    

wangzd / laravel-elasticsearch example snippets


'providers' => [

    // ...

    /**
     * Elasticsearch全文搜索
     */
    Wangzd\ScoutES\ESServiceProvider::class,
],

use App\Models\ShopSearchModel;
    
    Route::get('search', function () {
        // 为查看方便都转成数组
        dump(ShopSearchModel::search('搜索关键字')->get()->toArray());
    });