PHP code example of triadev / laravel-elasticsearch-mapping

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

    

triadev / laravel-elasticsearch-mapping example snippets


use Triadev\Es\Mapping\Facade\ElasticMapping;
use Triadev\Es\Mapping\Mapping\Blueprint;

ElasticMapping::map(function (Blueprint $blueprint) {
    // fluent syntax
    $blueprint->keyword('EXAMPLE')->boost(5);

    // attributes array syntax
    $blueprint->keyword('EXAMPLE', [
        'boost' => 5
    ]);

    // settings are used when creating a new index
    $blueprint->settings([
        'index' => [
            'number_of_replicas' => 10,
            'number_of_shards' => 12,
            'refresh_interval' => '30s'
        ]
    ]);
}, INDEX, TYPE);