Search
This is the official documentation of Forest Admin Cloud.
To improve your admin panel's search functionality, consider overriding the default search system with more efficient technologies. Options like PostgreSQL's tsquery
and tsvector
, Algolia, or Elasticsearch provide advanced search capabilities and faster query responses. These tools can significantly improve your app's search results and performance.
The following sections assume that you have correctly followed all the steps in the Code Customization Getting Started guide.
To make the code easier to read, all the code snippets below should be wrapped in the following code. Ensure you update the collection name as needed.
Extending the default search engine
To modify your collection's default search behavior, use the replaceSearch()
function. This function provides access to the default search logic through the context
argument.
Arguments:
excludedFields
* [String]: Remove the fields to the default search engine.extended
* Boolean: When activated, extended search also includes direct relationships.includeFields
* [String]: Add the fields to the default search engine.
The generateSearchFilter()
function returns an object containing the set of rules for searching. You can adjust these rules to better fit your needs or to make your searches more efficient.
Examples
Enabling case-sensitivity
By default, searches are case insensitive. To enable case-sensitive searches, switch from the IContains
operator to the Contains
operator.
Searching on specific columns based on user input format
To improve the default search functionality, this example below differentiates between a product reference (e.g., bcdaefCFABDEdfEF
) and a barcode value (e.g., 9876543210
) using regex. This enables the search to target the appropriate field based on the input type.
Using an external API
When your data is stored and organized in a cloud-based service, another storage system, or a service specifically for searching through text, you can opt to use these instead of the default search engine.
Last updated