Restrict the search on specific fields
Sometimes, searching on all fields is not relevant and may even involve big performance issues. You can restrict the search on specific fields only using the option searchFields.
SQL
Mongodb
Rails
In this example, we configure Forest Admin to only search on the fields name and industry of our collection companies.
/forest/companies.js
1
const { collection } = require('forest-express-sequelize');
2
3
collection('companies', {
4
searchFields: ['name', 'industry'],
5
});
Copied!
In this example, we configure Forest to only search on the fields name and industry of our collection companies.
/forest/companies.js
1
const { collection } = require('forest-express-mongoose');
2
3
collection('companies', {
4
searchFields: ['name', 'industry'],
5
});
Copied!
In this example, we configure Forest to only search on the fields name and industry of our collection Company.
/lib/forest_liana/collections/company.rb
1
class Forest::Company
2
include ForestLiana::Collection
3
4
collection :Company
5
6
search_fields ['name', 'industry']
7
8
action 'Mark as Live'
9
10
# ...
11
end
Copied!
Last modified 11mo ago
Copy link