diff --git a/content/collections/pages/5-to-6.md b/content/collections/pages/5-to-6.md index a7f06f970..08ff56f17 100644 --- a/content/collections/pages/5-to-6.md +++ b/content/collections/pages/5-to-6.md @@ -200,6 +200,31 @@ $globalSet->in('en')->data(['foo' => 'bar'])->save(); // [tl! add] $globalSet->in('en')->delete(); // [tl! add] ``` +### Search: `'searchables' => 'all'` +**Affects apps using `'searchables' => 'all'` in their search config.** + +Previously, you could set `'searchables' => 'all'` on a search index to include entries, terms, assets, users and anything provided by [custom searchables](/frontend/search#custom-searchables). + +However, in v6, to split out search between the frontend and the Control Panel, support for `'searchable' => 'all'` has been removed. + +You can now either use `'searchables' => 'content'` - which includes entries, terms and assets (**not** users) - or explicitly list [the searchables](/frontend/search#searchables) you want: + +```php +// config/statamic/search.php + +'indexes' => [ + + 'default' => [ + 'driver' => 'local', + 'searchables' => ['collection:blog', 'taxonomy:categories', 'assets:*'], + 'fields' => ['title'], + ], + +], +``` + +We’ve avoided automating this migration so you can intentionally decide whether users should be included. + ### Breadcrumbs **Affects apps or addons displaying breadcrumbs in the Control Panel.** diff --git a/content/collections/pages/search.md b/content/collections/pages/search.md index b9966d71f..3e2f8e8b0 100644 --- a/content/collections/pages/search.md +++ b/content/collections/pages/search.md @@ -91,7 +91,7 @@ Your site's default index includes _only_ the title from _all_ collections. The ``` php 'default' => [ 'driver' => 'local', - 'searchables' => 'all', + 'searchables' => 'content', 'fields' => ['title'], ], ``` @@ -294,7 +294,7 @@ de: 'indexes' => [ 'default' => [ 'driver' => 'local', - 'searchables' => 'all', + 'searchables' => 'content', ] ] ``` @@ -305,7 +305,7 @@ By default, all entries will go into the `default` index, regardless of what sit 'indexes' => [ 'default' => [ 'driver' => 'local', - 'searchables' => 'all', + 'searchables' => 'content', 'sites' => ['en', 'fr'], // You can also use "all" [tl! ++ **] ] ] @@ -337,7 +337,7 @@ You may provide local driver specific settings in a `settings` array. ```php 'driver' => 'local', -'searchables' => 'all', +'searchables' => 'content', // [tl! **:start] 'min_characters' => 3, 'use_stemming' => true, @@ -381,7 +381,7 @@ Algolia is a full-featured search and navigation cloud service. They offer fast ``` php 'default' => [ 'driver' => 'algolia', - 'searchables' => 'all', + 'searchables' => 'content', ], ``` @@ -403,7 +403,7 @@ You may provide Algolia-specific [settings](https://www.algolia.com/doc/api-refe ```php 'driver' => 'algolia', -'searchables' => 'all', +'searchables' => 'content', 'settings' => [ // [tl! **:start] 'attributesForFaceting' => [ 'filterOnly(post_tags)', @@ -434,6 +434,31 @@ You can also add values to the drivers array, which will cascade down to any ind Any values you add to an individual index will only be applied there. +## Control Panel + +Statamic configures a `cp` search index behind the scenes, used by the Command Palette. + +By default, it uses the `local` driver and includes content (entries/terms/assets), users, and any addon-provided searchables. + +You can override the configuration in your `search.php` config file: + +```php +// config/statamic/search.php + +'indexes' => [ + + // ... + + 'cp' => [ + 'driver' => 'local', + 'searchables' => ['content', 'users', 'addons'], + 'fields' => ['title'], + ], + +], +``` + + ## Digging deeper Search is split into a handful of different parts behind the scenes. @@ -621,6 +646,18 @@ public function boot() ] ``` +You can also include your searchable in the `content` or `addons` wildcard searchables, which are used by default for front-end and Control Panel searches. + +```php +// Pass the handle... +Search::addContentSearchable('product'); +Search::addCpSearchable('order'); + +// Or the provider class... +Search::addContentSearchable(ProductsProvider::class); +Search::addCpSearchable(OrdersProvider::class); +``` + #### Event Listeners You will want to update the indexes when you create, edit, or delete your searchable items.