The package settings live in config/scout-redis-search.php. Keep this file
separate from Laravel Scout’s config/scout.php:
// config/scout.php
'driver' => env('SCOUT_DRIVER', 'collection'),
// config/scout-redis-search.php
'prefix_matching' => env('SCOUT_REDIS_SEARCH_PREFIX_MATCHING', true),
config/scout.php selects the redis-search driver. The package configuration
defines how that driver connects to Redis and creates RediSearch indexes.
return [
'connection' => env('SCOUT_REDIS_SEARCH_CONNECTION'),
'prefix' => env('SCOUT_REDIS_SEARCH_PREFIX', 'scout:'),
'separator' => env('SCOUT_REDIS_SEARCH_SEPARATOR', ':'),
'prefix_matching' => env('SCOUT_REDIS_SEARCH_PREFIX_MATCHING', true),
'prefix_min_length' => env('SCOUT_REDIS_SEARCH_PREFIX_MIN_LENGTH', 2),
'schemas' => [
'users' => [
'fields' => [
'id' => ['type' => 'NUMERIC', 'sortable' => true],
'name' => ['type' => 'TEXT', 'sortable' => true],
'email' => 'TAG',
'__scout_key' => 'TAG',
],
],
],
];
Connection and document keys
| Key | Default | Purpose |
|---|---|---|
connection |
null |
Laravel Redis connection name |
prefix |
scout: |
Prefix for stored hash keys |
separator |
: |
Separator between index and Scout key |
prefix_matching |
true |
Compile terms such as Ad as Ad* |
prefix_min_length |
2 |
Minimum term length for prefix matching |
A document key is built as {prefix}{index}{separator}{scout_key}. With the
defaults, user 42 is stored at scout:users:42.
Schema formats
The readable format is recommended:
'schemas' => [
'articles' => [
'options' => ['LANGUAGE', 'English'],
'fields' => [
'title' => ['type' => 'TEXT', 'weight' => 2.0],
'body' => 'TEXT',
'category' => 'TAG',
'published_at' => ['type' => 'NUMERIC', 'sortable' => true],
'__scout_key' => 'TAG',
],
],
],
Supported field types are TEXT, TAG, NUMERIC, GEO, VECTOR, and
GEOSHAPE. Use TAG for exact filters, NUMERIC for ranges, and SORTABLE
for fields used with orderBy.
The previous raw argument-list format remains supported:
'articles' => [
'title', 'TEXT', 'WEIGHT', 2.0,
'body', 'TEXT',
'category', 'TAG',
'__scout_key', 'TAG',
],
__scout_key is written automatically by the engine and should be present in
every schema.
Configuration changes
RediSearch schemas are applied when the index is created. After changing a schema, recreate and import the index:
php artisan scout:delete-index users
php artisan scout:index users
php artisan scout:import "App\Models\User"