Advanced Search replaces Filament table’s search field with powerful search constraints and column selection. In addition to the default “contains” search, your users can now search using eight different constraints like “starts with”, “matches”, “ends with”, and more. Users can also select which columns to search, and even use keyboard syntax shortcuts to quickly change the search behavior directly from the search input. Advanced Search is fully integrated with Preset Views, User Views, and Quick Filters.
Enabling Advanced Search
Advanced Search is currently in beta. To use the feature you’ll need to update your composer.json file to:advancedSearchEnabled() to your panel provider:
Note: Advanced Search is automatically disabled on tables that use Filament’s ->searchUsing() callback.
After enabling, be sure to run npm run build and php artisan filament:upgrade.
Using Advanced Search
Once enabled, the search field will display a settings button (gear icon) next to the search input. Clicking this button opens a dropdown with the following options:- Search method - A dropdown to select the search constraint (e.g., Contains, Starts with, Matches).
- Search columns - Checkboxes to select which columns to include in the search. Only displayed when there are two or more searchable columns.
Search Constraints
Advanced Search includes eight search constraints:| Constraint | Description | SQL Operator |
|---|---|---|
| Contains | Matches records containing the search term anywhere | like %value% |
| Does not contain | Excludes records containing the search term | not like %value% |
| Matches | Matches records where the value is exactly the search term | = value |
| Does not match | Excludes records where the value is exactly the search term | != value |
| Starts with | Matches records starting with the search term | like value% |
| Does not start with | Excludes records starting with the search term | not like value% |
| Ends with | Matches records ending with the search term | like %value |
| Does not end with | Excludes records ending with the search term | not like %value |
Search Shortcuts
Instead of using the dropdown, users can type a syntax prefix directly in the search field to quickly change the search constraint:| Shortcut | Constraint | Example |
|---|---|---|
| (none) | Contains | order |
- | Does not contain | -order |
= | Matches | =order |
-= | Does not match | -=order |
^ | Starts with | ^order |
-^ | Does not start with | -^order |
$ | Ends with | $order |
-$ | Does not end with | -$order |
Tip: The information icon next to the search method dropdown displays all available shortcuts for quick reference.
Exact Phrase Search
Wrap your search term in quotes to match the full phrase. For example,"John Doe" will match records containing the exact phrase “John Doe” rather than matching “John” and “Doe” separately.
Using with Preset Views
You can apply default search settings to your Preset Views using thedefaultSearch() method:
defaultSearch() method accepts the following parameters:
| Parameter | Type | Description |
|---|---|---|
$search | string | Closure | null | The search term |
$constraint | string | SearchConstraint | Closure | null | The search constraint (e.g., 'starts_with', SearchConstraint::StartsWith) |
$columns | array | Closure | null | An array of column names to search |
Using with User Views
Advanced Search settings are automatically saved and restored with User Views. When a user saves a User View, the active search term, search constraint, and selected columns are included. When the User View is loaded, all search settings are restored.Advanced Search configurations
Advanced Tables offers multiple ways to customize Advanced Search. Unless specified otherwise, these options can be configured directly on theAdvancedTablesPlugin object inside your PanelProvider.
Disabling Advanced Search
Advanced Search is disabled by default and must be enabled in your panel provider. If you have enabled it globally but want to disable it for a specific table, you may override theadvancedSearchIsEnabled() method on your List page:
Customizing the trigger action
You can customize the Advanced Search trigger button usingadvancedSearchTriggerAction(), following the same pattern as Filament’s trigger action customization:
Customizing the buttons and labels
You may customize Advanced Search labels in the language file. Publish the language files and update theadvanced_search section in the advanced-tables.php language file.