PHP code example of wannanbigpig / laravel-scout-elastic
1. Go to this page and download the library: Download wannanbigpig/laravel-scout-elastic 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/ */
wannanbigpig / laravel-scout-elastic example snippets
// config/scout.php
return [
// ...
'driver' => env('SCOUT_DRIVER', 'elasticsearch'),
// ...
/*
|--------------------------------------------------------------------------
| Elasticsearch Configuration
|--------------------------------------------------------------------------
|
| Here you may configure your Elasticsearch settings.
|
*/
'elasticsearch' => [
'hosts' => [env('ELASTICSEARCH_HOST', 'http://127.0.0.1:9200')],
// 'auth' => [
// 'username' => 'elastic',
// 'password' => 'password copied during Elasticsearch start',
// ],
// index_ is followed by the index name. If you do not need to customize the index analyzer, skip the following Settings
'index_article' => [
'settings' => [
'number_of_shards' => 5,
'number_of_replicas' => 1,
],
'mappings' => [
"properties" => [
"title" => [
"type" => "text",
"analyzer" => "ik_max_word",
"search_analyzer" => "ik_smart",
"fields" => ["keyword" => ["type" => "keyword", "ignore_above" => 256]],
],
],
],
],
],
];
shell
// create index
php artisan scout:index article
// delete index
php artisan scout:delete-index article
// batch update data to es
php artisan scout:import "App\Models\Article"
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.