PHP code example of statamic-rad-pack / meilisearch

1. Go to this page and download the library: Download statamic-rad-pack/meilisearch 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/ */

    

statamic-rad-pack / meilisearch example snippets


'drivers' => [

    // other drivers

    'meilisearch' => [
        'credentials' => [
            'url' => env('MEILISEARCH_HOST', 'http://localhost:7700'),
            'secret' => env('MEILISEARCH_KEY', ''),
            // 'search_api_key' => env('MEILISEARCH_SEARCH_KEY')
        ],
    ],
],

// articles
'articles' => [
    'driver' => 'meilisearch',
    'searchables' => ['collection:articles'],
    'fields' => ['id', 'title', 'url', 'type', 'content', 'locale'],
    'settings' => [
      'filterableAttributes' => ['type', 'locale'],
    ],
],

'articles' => [
    'driver' => 'meilisearch',
    'searchables' => ['collection:articles'],
    'settings' => [
        'filterableAttributes' => ['type', 'country', 'locale'],
        'distinctAttribute' => 'thread',
        'stopWords' => ['the', 'of', 'to'],
        'sortableAttributes' => ['timestamp'],
        'rankingRules' => [
          'sort',
          'words',
          'typo',
          'proximity',
          'attribute',
          'exactness',
        ],
    ],
 ],

// articles
'articles' => [
    'driver' => 'meilisearch',
    'searchables' => ['collection:articles'],
    'fields' => ['id', 'title', 'url', 'type', 'content', 'locale'],
    'pagination' => [
      'maxTotalHits' => 100,
    ],
],

class MyIndex extends Index {
    // Your custom logic here
}

// app/Providers/AppServiceProvider.php

$this->app->bind(\StatamicRadPack\meilisearch\meilisearch\Index::class, MyIndex::class);

php artisan vendor:publish --tag=statamic-meilisearch-config