Skip to content

Conversation

@duncanmcclean
Copy link
Member

@duncanmcclean duncanmcclean commented Nov 19, 2025

This pull request aims to separate "content searches" from "everything" searches, allowing addons to register searches that are used exclusively in the Control Panel.

Use case: In my e-commerce addon, Cargo, I want orders and discounts to appear in the Command Palette, but not be searchable on the frontend via the {{ search }} tag.

'searchables' => 'all'

Previously, you could set 'searchables' => 'all' on a search index to include entries, terms, assets, users and anything provided by custom searchables.

To split "content searches" (frontend) from "everything searches" (CP), 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 you want:

// 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.

Adding to content searchables

Addon developers can add their own searchables to the content wildcard like this:

// src/ServiceProvider.php

use Statamic\Facades\Search;

// Pass the handle...
Search::addContentSearchable('product');

// Or the provider class...
Search::addContentSearchable(ProductsProvider::class);

Command Palette search

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:

// config/statamic/search.php

'indexes' => [  

	// ...
  
    'cp' => [  
        'driver' => 'local',  
        'searchables' => ['content', 'users', 'addons'],  
        'fields' => ['title'],
    ],
    
],

Addon developers can add custom searchables to the cp index like this:

// src/ServiceProvider.php

use Statamic\Facades\Search;

// You can either pass the handle...
Search::addCpSearchable('order');

// Or, the provider class...
Search::addCpSearchable(OrdersProvider::class);

Closes statamic/ideas#240

Comment on lines +20 to +21
protected static array $cpSearchables = [];
protected static array $contentSearchables = [];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if these might be better off as container bindings? 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Separate control panel search and site search

2 participants