Search
In Forest Admin, pages which show lists of records have a free-text search widget on top of them.
Search modes
Two search modes are supported: normal and extended.
All searches start by being a "normal search".
If the result the user is looking for is not found, it is possible to trigger an extended search from the user interface.
Default behavior
When not defined otherwise by the data source, the search behavior is to attempt to search within columns of the collection (in normal mode), or columns of the collection of direct relations (in extended mode).
By default, Forest Admin will search only on some columns, depending on their respective types.
Enum
Column is equal to the search string (case-insensitive)
Number
Column is equal to the search string (if the search string is numeric)
String
Column contains the search string (case-insensitive)
Uuid
Column is equal to the search string
Other types
Column is ignored by the default search handler
Customization
You may want to change how the search bar behaves in your admin panel.
For instance:
Search only on the columns which are relevant to your use case.
Use full-text indexes of your data (i.e Postgres
tsquery
andtsvector
, Algolia, Elastic search, ...)
To customize the search bar, you must define a handler that returns a ConditionTree
.
Making the search case-sensitive by default
In this example, we use the searchExtended
condition to toggle between case-sensitive and insensitive searches.
Changing searched columns
Calling an external API
If your data is indexed using a SaaS, external store, or full-text index, you can call it in the search handler.
Last updated