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.

Lumber
Rails
Express/Sequelize
Express/Mongoose

In this example, we configure Forest Admin to only search on the fields name and industry of our collection companies.

/forest/companies.js
const Liana = require('forest-express-sequelize');
Liana.collection('companies', {
searchFields: ['name', 'industry'],
});

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
class Forest::Company
include ForestLiana::Collection
collection :Company
search_fields ['name', 'industry']
action 'Mark as Live'
# ...
end

In this example, we configure Forest to only search on the fields name and industry of our collection companies.

/forest/companies.js
const Liana = require('forest-express-sequelize');
Liana.collection('companies', {
searchFields: ['name', 'industry'],
});

In this example, we configure Forest to only search on the fields name and industry of our collection companies.

/forest/companies.js
const Liana = require('forest-express-mongoose');
Liana.collection('companies', {
searchFields: ['name', 'industry'],
});