Search
This is the official documentation of the @forestadmin/agent
Node.js agent.
In Forest Admin, pages that show lists of records have a free-text search bar on top of them.
Search modes
2 search modes are supported: "normal" and "extended".
All searches start by being a "normal" search.
If the records users are looking for are not found, it is possible to trigger an "extended" search from the footer.
Default behavior
Natively, the search behavior is to seek value occurrences within columns of the Collection (in normal mode), and columns of the Collections of direct relations (in extended mode).
By default, Forest Admin will search only in specific columns, depending on their type:
Customization
Alternatively, you may want to change how the search behaves in your admin panel.
For instance:
search only on the columns that are relevant to your use case.
use full-text indexes (i.e. Postgres
tsquery
andtsvector
, Algolia, Elastic search, ...)
Extending the default search
The context received by the function replaceSearch
can have access to the default search behavior and extend it:
The condition tree returned by generateSearchFilter
can be combined with other custom conditions:
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, an external store, or a full-text index, you can call it in the search handler.
Last updated