PHP code example of jeroen-g / explorer

1. Go to this page and download the library: Download jeroen-g/explorer 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/ */

    

jeroen-g / explorer example snippets


return [
    'indexes' => [
        'posts_index' => [
            'properties' => [
                'id' => 'keyword',
                'title' => 'text',
            ],
        ]
    ]
];

return [
    'indexes' => [
        \App\Models\Post::class
    ],
];

$posts = Post::search('lorem ipsum')->get();

$posts = Post::search('lorem')
    ->must(new Matching('title', 'ipsum'))
    ->should(new Terms('tags', ['featured'], 2))
    ->filter(new Term('published', true))
    ->get();
bash
php artisan vendor:publish --tag=explorer.config
bash
php artisan elastic:search "App\Models\Post" lorem