PHP code example of torann / laravel-hunt

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

    

torann / laravel-hunt example snippets


[
    'settings' => [
         'number_of_shards' => 1,
         'analysis' => [
             'filter' => [
                 'autocomplete_filter' => [
                     'type' => 'edge_ngram',
                     'min_gram' => 1,
                     'max_gram' => 20,
                 ],
             ],
             'analyzer' => [
                 'autocomplete' => [
                     'type' => 'custom',
                     'tokenizer' => 'standard',
                     'filter' => [
                         'lowercase',
                         'autocomplete_filter',
                     ],
                 ],
             ],
         ],
     ],
]

protected $mappingProperties = [
   'title' => [
        'type' => 'string',
        'analyzer' => 'standard'
    ]
];

$post = new App\Post;

// ...

$post->save();

$post = App\Post::find(1);

// Update the post...

$post->save();

$post = App\Post::find(1);

$post->delete();

$posts = App\Post::search('Kitten fluff')->get();

use Illuminate\Http\Request;

Route::get('/search', function (Request $request) {
    return App\Post::search($request->search)->get();
});

$posts = App\Post::search('Kitten fluff')->paginate();

$posts = App\Post::search('Kitten fluff')->paginate(15);
 php
'providers' => [

    LaravelHunt\LaravelHuntServiceProvider::class,

]
 php
$app->register(LaravelHunt\LaravelHuntServiceProvider::class);