Optimize the search experience
Generate index settings
Performance is important. On top of that, for a search to be successful, results need to be relevant to users. Scout Extended provides ascout:optimize
Artisan command that you may use to optimize the search experience based on information from the searchable
class:
scout:optimize
tries to generate the settings of your searchable
class index, but you may need to edit those settings in config/scout-articles.php
:
PHP
Synchronize index settings
Once you have verified the settings file, all you need to do is synchronize the settings with Algolia using thescout:sync
Artisan command:
You can also edit settings using the Algolia dashboard.
Make sure to apply these settings locally with the
scout:sync
Artisan command if you do this, or your changes will be lost.Custom settings path
By default, all settings live inconfig/scout-{index-name}.php
. You can change this by setting the settings_path
in the config/scout.php
configuration file:
PHP
Custom index name
To customize the index name, you should implement thesearchableAs
method
in your searchable
class.
If you customize the index name, you must include the index prefix by using
config('scout.prefix')
. Without this prefix, the scout:reimport
won’t work as expected.searchableAs
method concatenates the prefix
configuration key defined in config/scout.php
and the table name. As usual, you can change this behavior:
PHP
Per-environment index name
Scout reads the prefix from your environment variables. If you need different indices for each environment, you should define a differentPREFIX
in your .env
file.