Search
Last updated
Was this helpful?
Last updated
Was this helpful?
This is the official documentation of the agent_ruby
Ruby agent.
In Forest Admin, pages that show lists of records have a free-text search bar on top of them.
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.
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:
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.
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
and tsvector
, Algolia, Elastic search, ...)
In this example, we use the searchExtended
condition to toggle between case-sensitive and insensitive searches.
If your data is indexed using a SaaS, an external store, or a full-text index, you can call it in the search handler.
You can remove the search bar by disabling the search on a collection:
If you want to make a column searchable, you must define the right operator to allow the search to be performed. Please refer to the table to know which operator to define.
To customize the search behavior, you must define a handler that returns a .
By default, the search bar is displayed when at least one field supports the operator used for search based on its type ().